A seven-segment display shows numbers using light segments. Controlling it lets you show digits on devices like clocks or counters.
Displaying numbers on a digital clock.
Showing scores in a game.
Counting items on a simple counter.
Displaying temperature readings on a small device.
Creating a simple calculator output.
Syntax
Arduino
void setup() {
// Set pins as outputs
pinMode(pin1, OUTPUT);
pinMode(pin2, OUTPUT);
...
}
void loop() {
// Turn on/off segments to show a digit
digitalWrite(pin1, HIGH or LOW);
digitalWrite(pin2, HIGH or LOW);
...
delay(time_in_ms);
}
Each segment of the display connects to a pin on the Arduino.
Setting a pin HIGH or LOW turns a segment on or off.
Examples
Turns on one segment and turns off another.
Arduino
digitalWrite(2, HIGH); // Turn on segment connected to pin 2
digitalWrite(3, LOW); // Turn off segment connected to pin 3
Sets pin 4 as output to control a segment.
Arduino
pinMode(4, OUTPUT); // Prepare pin 4 to control a segment
Pauses the program so the digit stays visible.
Arduino
delay(1000); // Wait for1 second before changing display
Sample Program
This program lights up the segments to show digits 0 through 9 one by one, each for one second.
Sending HIGH voltage turns the connected segment on.
Final Answer:
The segment will turn on -> Option B
Quick Check:
digitalWrite HIGH = segment ON [OK]
Hint: HIGH signal turns segment on, LOW turns it off [OK]
Common Mistakes:
Thinking HIGH turns segment off
Assuming blinking without delay code
Confusing pinMode with digitalWrite effects
4. This Arduino code is intended to display the digit '1' on a common cathode seven-segment display connected to pins 2 and 3 for segments B and C respectively:
Pins should be set to HIGH to turn on segments on a common cathode display -> Option A
Quick Check:
Common cathode ON = HIGH signal [OK]
Hint: Common cathode segments light with HIGH signal [OK]
Common Mistakes:
Setting pins LOW instead of HIGH for common cathode
Thinking pins 2 and 3 can't be outputs
Ignoring pinMode setup
5. You want to display digits 0 to 9 sequentially on a common anode seven-segment display using Arduino. Which approach correctly controls the segments to show each digit?
hard
A. Connect all segment pins to 5V and use delay to show digits
B. Set segment pins HIGH to turn on segments, LOW to turn off, and update pins for each digit
C. Use analogWrite to vary brightness of segments for each digit
D. Set segment pins LOW to turn on segments, HIGH to turn off, and update pins for each digit
Solution
Step 1: Understand common anode display logic
Common anode means segments turn on when pins are LOW (connected to ground).
Step 2: Control segments for digits 0-9
Set pins LOW for segments to light, HIGH to turn off, update pins per digit pattern.
Final Answer:
Set segment pins LOW to turn on segments, HIGH to turn off, and update pins for each digit -> Option D
Quick Check:
Common anode ON = LOW signal [OK]
Hint: Common anode segments light with LOW signal [OK]
Common Mistakes:
Using HIGH to turn on segments on common anode
Using analogWrite instead of digitalWrite for digits
Connecting all pins to 5V without control
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.