| The M32 can drive 7-segment LED
displays directly without a driver chip. Click the image below to
see the schematic for driving 2 displays. This examples shows
a pair of NTE3078 common anode LED displays connected directly to 2
ports on an M32 controller. By writing the appropriate value
to each port, you can display any number.

Sample Bascom Code
'Driving
7-Segment LED Displays with an M32
'See above for
the schematic used
'Wright
Hobbies, LLC
'eddy@wrighthobbies.com
'Dimension
Variables
Dim
Number(10)
As
Byte
'This stores
the proper binary value to display the number desired
Dim
I As
Byte
,
X As
Byte
'Define
Constants
Const
Blank =
&B1111111
'Turn off all
elements in display
'Assign Values to Number()
'I am using
binary to show the correlation of segments to bits, but you could
also use 'decimal values
Number(1)
=
&B11111001
Number(2)
=
&B10100100
Number(3)
=
&B10110000
Number(4)
=
&B10011001
Number(5)
=
&B10010010
Number(6)
=
&B10000010
Number(7)
=
&B11111000
Number(8)
=
&B10000000
Number(9)
=
&B10010000
Number(10)
=
&B01000000
'Arrays start
with element 1, so this is zero
'Configure the
port direction
Config
Porta
=
Output
Config
Portd
=
Output
Porta
=
Blank
Portb
=
Blank
Wait
1
'Main loop
'This isn't
accurate, it's to only to show how to display the numbers
'To create an
accurate timer, use one of the hardware timers
I =
1
Do
Porta
=
Number(i)
'Show the
number
Wait
1 'wait about 1
second
I =
I +
1 'show the
next number
If
I >
10 Then
I =
1 'loop back to
number 1
Loop
End
|