This is a Common Cathode 7 Segment display example.
No additional configuration is required when using Common Cathode.
| Constant Name | Controls | Comment |
|---|---|---|
|
|
Inverts controls for Common Anode displays |
Required for Common Anode displays — omit this constant for Common Cathode displays |
|
|
Support PFET or PNP high side driving of the display |
Inverts Common Cathode addressing pin logic for multiplexed displays |
This is a Common Cathode 7 Segment display example.
Example:
'Chip model
#chip 16f1783,8
'Output ports for the 7-segment device
#define DISP_SEG_A PORTC.0
#define DISP_SEG_B PORTC.1
#define DISP_SEG_C PORTC.2
#define DISP_SEG_D PORTC.3
#define DISP_SEG_E PORTC.4
#define DISP_SEG_F PORTC.5
#define DISP_SEG_G PORTC.6
' This is the usage of the SEG_DOT for decimal point support
' An optional third parameter of '1' will turn on the decimal point
' of that digit when using DisplayValue command
#define DISP_SEG_DOT PortC.7
'Select ports for the 7-segment device
#define Disp_Sel_1 PortA.1
#define Disp_Sel_2 PortA.2
#define Disp_Sel_3 PortA.3
dim count as word
dim number as word
Do Forever
For count = 0 to 999
number = count
Num2 = 0
Num3 = 0
If number >= 100 Then
Num3 = number / 100
'SysCalcTempX is the remainder after a division has been completed
number = SysCalcTempX
End if
If number >= 10 Then
Num2 = number / 10
number = SysCalcTempX
end if
Num1 = number
Repeat 10
DisplayValue 1, Num1,1 'Optional third parameter turns on the dp dot on that digit ' <<< the DisplayValue instruction
wait 5 ms
DisplayValue 2, Num2
wait 5 ms
DisplayValue 3, Num3
wait 5 ms
end Repeat
Next
LoopKey line: DisplayValue 1, Num1,1 — writes Num1 to digit 1 of the display, with the optional third parameter of 1 also lighting that digit’s decimal point; no 7Seg_CommonAnode define is needed here because this is a Common Cathode display.
See Also:
- 7 Segment Display Overview — category overview
- DisplayChar — displaying a single character instead of a full multi-digit value
- DisplayValue — full reference for the command used above
- Common Anode — the counterpart wiring, which requires the
7Seg_CommonAnodeconstant

