Controlling a Seven-Segment Display Using Arduino Part 4
The third and final Arduino sketch uses bits to represent each segment and is a reduced code version of the previous sketch (1,210 bytes for sketch #3 instead of 1,852 bytes for sketch #2). A ten element array holds a byte for each number 0-9 that specifies what segments should be lit (pin low). Bit 0 corresponds to segment A, bit 1 to segment B and so on. In order to display the number 1, segments B and C need to be lit, so that is represented by the value 0b1111001. Function “lightSegments” reads these bits in sequence and sets the corresponding segments accordingly.
Controlling a Seven-Segment Display Using Arduino Part 3
The second sketch cycles through the numbers from 0 to 9, but only increments the display counter each time a button is pressed. Note that this code includes simple debouncing by introducing a short delay when the Arduino detects that the button has been pressed.
Controlling a Seven-Segment Display Using Arduino Part 2
This month’s project is a simple program to display the Arabic numbers using the Arduino and a 7-segment display.
Parts list:









