Display Structure and Theory
Seven-Segment Display:
A 7-segment display consists of seven LEDs (segments) arranged in a figure-8 pattern, plus an optional decimal point. By lighting different combinations of segments, we can display digits 0-9 and some letters.
Segment Labeling:
A 7-segment display consists of seven LEDs (segments) arranged in a figure-8 pattern, plus an optional decimal point. By lighting different combinations of segments, we can display digits 0-9 and some letters.
Segment Labeling:
AAA
F B
F B
GGG
E C
E C
DDD DP
Types:
- Common Cathode: All cathodes connected together to GND. Set pins HIGH to light segments.
- Common Anode: All anodes connected together to VCC. Set pins LOW to light segments.
Segment-to-Pin Mapping
| Segment | Position | Example Pin |
|---|---|---|
| A | Top | Pin 2 |
| B | Top Right | Pin 3 |
| C | Bottom Right | Pin 4 |
| D | Bottom | Pin 5 |
| E | Bottom Left | Pin 6 |
| F | Top Left | Pin 7 |
| G | Middle | Pin 8 |
| DP | Decimal Point | Pin 9 |
Digit Encoding Table
| Digit | A | B | C | D | E | F | G | Binary | Hex |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0111 1110 | 0x7E |
| 1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0011 0000 | 0x30 |
| 2 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 0110 1101 | 0x6D |
| 3 | 1 | 1 | 1 | 1 | 0 | 0 | 1 | 0111 1001 | 0x79 |
| 4 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 0011 0011 | 0x33 |
| 5 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0101 1011 | 0x5B |
| 6 | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 0101 1111 | 0x5F |
| 7 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0111 0000 | 0x70 |
| 8 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0111 1111 | 0x7F |
| 9 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 0111 1011 | 0x7B |
Current Limiting Calculations
LED Specifications:
Forward voltage (Vf): 2.0V (red segments)
Forward current (If): 10-20mA typical
Resistor Calculation per Segment:
R = (Vsupply - Vf) / If
R = (5V - 2.0V) / 0.015A = 200Ω
Use 220Ω (standard value): I = 3V / 220Ω = 13.6mA ✓
Total Current (All Segments ON):
8 segments × 13.6mA = 108.8mA
Note: Arduino pins can source ~40mA max, sink ~40mA max.
Solution: Use current-limiting resistors OR driver IC (74HC595, MAX7219)
Forward voltage (Vf): 2.0V (red segments)
Forward current (If): 10-20mA typical
Resistor Calculation per Segment:
R = (Vsupply - Vf) / If
R = (5V - 2.0V) / 0.015A = 200Ω
Use 220Ω (standard value): I = 3V / 220Ω = 13.6mA ✓
Total Current (All Segments ON):
8 segments × 13.6mA = 108.8mA
Note: Arduino pins can source ~40mA max, sink ~40mA max.
Solution: Use current-limiting resistors OR driver IC (74HC595, MAX7219)
Circuit Diagram - Common Cathode
7-Segment Display (Common Cathode)
Pin 2 ---[220Ω]---> Segment A
Pin 3 ---[220Ω]---> Segment B
Pin 4 ---[220Ω]---> Segment C
Pin 5 ---[220Ω]---> Segment D
Pin 6 ---[220Ω]---> Segment E
Pin 7 ---[220Ω]---> Segment F
Pin 8 ---[220Ω]---> Segment G
Pin 9 ---[220Ω]---> Segment DP
Common Pin(s) ----> GND
🎛️ DIP Switch
DIP Switch Theory and Operation
DIP Switch (Dual In-line Package):
A DIP switch is a set of manual electric switches packaged in a standard IC form factor. Each switch can be independently set to ON or OFF.
Common Types:
A DIP switch is a set of manual electric switches packaged in a standard IC form factor. Each switch can be independently set to ON or OFF.
Common Types:
- SPST (Single Pole Single Throw): Simple ON/OFF per switch
- Slide: Linear motion to toggle
- Rocker: Rocking motion to toggle
- Rotary: Circular positions
- Configuration selection (address, mode)
- Binary input (8-bit DIP = 256 combinations)
- Feature enable/disable
- Hardware settings without code changes
Pull-up vs Pull-down Configuration
| Configuration | Switch OFF | Switch ON | Advantages |
|---|---|---|---|
| Pull-up (resistor to +5V) |
Pin reads HIGH | Pin reads LOW | Uses INPUT_PULLUP mode No external resistors needed |
| Pull-down (resistor to GND) |
Pin reads LOW | Pin reads HIGH | More intuitive (ON=HIGH) Requires external resistors |
Circuit Diagram - Pull-up Configuration
8-Position DIP Switch (Internal Pull-ups)
Switch 1 --+---> Pin 2
|
GND
Switch 2 --+---> Pin 3
|
GND
Switch 3 --+---> Pin 4
|
GND
... (continue for all switches)
Configure pins with INPUT_PULLUP:
pinMode(pin, INPUT_PULLUP);
Reading:
OFF = HIGH (pulled up to 5V)
ON = LOW (connected to GND)
Binary Encoding Example
8-bit DIP Switch as Binary Input:
Switch positions (1=ON, 0=OFF): 0 0 1 0 1 1 0 1
Bit values (MSB to LSB): 2⁷ 2⁶ 2⁵ 2⁴ 2³ 2² 2¹ 2⁰
Decimal value = 0×128 + 0×64 + 1×32 + 0×16 + 1×8 + 1×4 + 0×2 + 1×1
= 32 + 8 + 4 + 1
= 45
Reading in Code:
value = 0;
for(int i = 0; i < 8; i++) {
if(digitalRead(pins[i]) == LOW) { // ON
value |= (1 << i);
}
}
Switch positions (1=ON, 0=OFF): 0 0 1 0 1 1 0 1
Bit values (MSB to LSB): 2⁷ 2⁶ 2⁵ 2⁴ 2³ 2² 2¹ 2⁰
Decimal value = 0×128 + 0×64 + 1×32 + 0×16 + 1×8 + 1×4 + 0×2 + 1×1
= 32 + 8 + 4 + 1
= 45
Reading in Code:
value = 0;
for(int i = 0; i < 8; i++) {
if(digitalRead(pins[i]) == LOW) { // ON
value |= (1 << i);
}
}
Debouncing Considerations
DIP Switch Debouncing:
Unlike push buttons, DIP switches are typically toggled manually and held in position. However, they still exhibit mechanical bounce during the transition.
Solutions:
Unlike push buttons, DIP switches are typically toggled manually and held in position. However, they still exhibit mechanical bounce during the transition.
Solutions:
- Software Delay: Read, wait 50ms, read again
- State Change Detection: Only act on transitions, not continuous reading
- Ignore During Setup: For configuration switches, read once at startup
Common Applications
| Switches | Range | Application |
|---|---|---|
| 4-bit | 0-15 | Device address, simple modes |
| 8-bit | 0-255 | Extended addressing, settings |
| Individual | N/A | Feature flags, enable/disable |
Use Cases
- Networking: Device ID, subnet configuration
- Industrial Control: Machine mode selection
- Embedded Systems: Boot mode, debug enable
- Audio Equipment: Input selection, gain settings
- Multi-Device Systems: Address assignment
Combined Demo Concept: 7-Segment + DIP Switch
Demonstration Idea:
Use a 4-bit DIP switch to select a hexadecimal digit (0-F) and display it on the 7-segment display. This demonstrates binary-to-hexadecimal conversion and visual output.
System Operation:
Use a 4-bit DIP switch to select a hexadecimal digit (0-F) and display it on the 7-segment display. This demonstrates binary-to-hexadecimal conversion and visual output.
System Operation:
- Read 4-bit value from DIP switches (0-15)
- Convert to corresponding 7-segment pattern
- Display digit (0-9, A-F)
- Update display when switch changes