Arduino mega pinout chart
This is done by the setRow function, that has the row and the corresponding element of the smiley array as argument. Like in the first example, we only have to loop over the 8 rows of the dot matrix display and define which LEDs should turn on. In the loop function we start to draw the three faces. In the last step of the setup function we make sure that alle LEDs are turned off with the clearDisplay function. We set the brightness to a medium value of 5. Also the brightness can be controlled with the setIndensity function between 0 and 15.
In the setup function we set the power saving mode to false that can be called with the shutdown function. Each array has 8 elements for a 8×8 dot matrix display.
In the next part of the script we define the arrays that contain the binary codes which LED dots should turn on to create a happy face (hf), a neural face (nf) and a sad face (sf). The following video shows how the values 0 to 4 are displayed in the segment display with the use of an Arduino Uno and the 74HC595 shift register. Allowed data types: byte.Īfter all states for the LED are loaded to the shift register, the shift register clock (LATCH) is set from LOW to HIGH to forward all values to the 7 segment display for the visualization. bitOrder: which order to shift out the bits either MSBFIRST or LSBFIRST.clockPin: the pin to toggle once the dataPin has been set to the correct value.dataPin: the pin on which to output each bit.Now we use the shiftOut function, shiftOut(dataPin, clockPin, bitOrder, value), to shift out a byte of data one bit at a time ( reference): For each element in the num array we set the latch pin low to load the different states of the shift register. In the loop function we have to iterate through the num array to display all digits before the loop function starts again. We only have to loop through the LEDs array with a for loop and set the pinMode of the desired element in the array as output. You could define each pin as output separat line after line, but we have our array that makes the definition as output very easy. In the setup function we define each pin that connects the microcontroller and the display as output, because we want to control the display from the view of the microcontroller. We save the combination of values also in an array. Because my 7 segment display has a cathode configuration, the 1 is displayed with 0000110 and 8 with 1111111. You can use the table for the anode or cathode configuration to see which of the 7 pins has to be 0 (LOW) or 1 (HIGH).
#Arduino mega pinout chart how to
You can either comment the other lines or delete them, if you do not need them.īecause we want to display the numbers 1 and 8, we have to define how to control all digital I/O pins to get the desired numbers. Depending on your microcontroller, you only have to select one of the first three lines. Later we can access every element in the array to make our lives a little easier. Therefore I explain the Arduino script in detail.Īt the beginning of the script we create an array, called LEDs that stores all the connection pins to the 7 segment display. The script is a bit tricky if you did not use arrays before.