Karnataka KSEAB SSLC NSQF Electronics and Hardware study materials
Karnataka KSEAB SSLC NSQF Electronics and Hardware study resources

Seven-Segment Display Shows 8 and Then Only the Middle Bar

Karnataka KSEAB SSLC NSQF Electronics and Hardware · Put your knowledge to work in context.

All case studies

Seven-Segment Display Shows 8 and Then Only the Middle Bar

An SSLC student is building a 0–9 counter using a common-anode seven-segment display and an Arduino Uno. Each segment is connected through a 220 Ω resistor to a digital pin. The display's common pin is connected to 5 V. In the first test, the code writes 0x00 to the segment port, and the display shows 8. When the code writes 0x3F, the display shows only the middle bar and the decimal point. The student concludes the display is faulty and wants to replace it. The code comment says 0x3F is the pattern for 0. The display datasheet says forward voltage about 2.0 V per segment at 10 mA, and the Arduino absolute maximum per pin is 40 mA, with 20 mA recommended. All eight segments can be on at once.

1. Explain the two observed patterns and why the display is not faulty.

Read the worked answer

The display is common-anode, so a segment turns on when its pin is LOW, sinking current to ground. 0x00 means all bits are low, so all segments turn on and the display shows 8.

0x3F is 0011 1111. Bits 0–5 are high, so segments a–f are off; bits 6 and 7 are low, so segment g and the decimal point turn on. That gives the middle bar and the dot. The code is written as if the display were common-cathode and active-high. The display is responding correctly to the electrical levels.

2. Give the correct pattern for 0 on this display and explain how to handle the segment current.

Read the worked answer

For a common-anode display, invert the common-cathode pattern. For 0, segments a–f must be on and g off. Assuming a is bit 0, bits a–f are 0, g is 1, and dp is 1: 1100 0000 = 0xC0. Send 0xC0.

Current per segment = (5 V − 2 V) / 220 Ω ≈ 13.6 mA. With all eight segments on, total current is about 109 mA. Each pin is within the 20 mA recommended limit, but the total is close to the Uno's recommended limit. Use 330 Ω to reduce each segment to about 9 mA, or use a driver transistor or IC if brightness or more digits are needed.

3. What would change if the display were common-cathode instead?

Read the worked answer

For a common-cathode display, the common pin goes to ground and a segment turns on when its pin is HIGH. 0x3F would then be correct for 0: segments a–f high, g low.

The current direction reverses: the Arduino sources current instead of sinking it. The common pin must carry all segment currents, so a transistor is often used on the common pin when all segments are on. The code becomes active-high, and the wiring common pin moves from 5 V to ground.