7 Segment Display

A 7 segment display is made up of eight LEDs. Seven of those form the digit and one for the dot. You might recall the RGB LED had a common cathode (only one pin connected to ground). This display is common anode, so you connect one pin to power and then each individual LED leg through a resistor to a pin on the GCDuino.

CIRCUIT:

7 Segment

CODE:

Jumping right in the deep end here. We have a 2 dimensional array that defines what pins have to be off to light that number. So if we look at zero {1,1,1,0,1,1,0,1}, The first number 1, is digital pin 10. The next is D11, and so on until the last one is D17. Analog pins A0 to A5 have a digital definition as well, D14 to D19.

In the Setup, we loop from 10 to 17, setting the pinMode and digitally writing a high to that pin. We right the high because the display is common anode. Meaning high is off and low is on.

The first for loop we come to counts from row 9 down to row 0 of our array. Inside that we count across the array, from 0 to 7 and write the reverse of that state to the digital pin. Confusing enough?

Leave a Reply

Your email address will not be published. Required fields are marked *