7 Segmentns and hc595
The_Apprentice
Posts: 15
HI, can some body give a tip in how to display numbers on the 7 segments, i'm running this code, the pattern change segment by segment in order, I try to modify the patter to see if I can get some numbers, but i coudn't. Please if any body can help me i will really appreciate.
INCLUDE "modedefs.bas"
Clock CON 0 ' shift clock (74HC595.11)
DataOut CON 1 ' serial data out (74HC595.14)
Latch CON 2 ' output latch (74HC595.12)
DelayTime CON 100
pattern VAR Byte ' output pattern
Initialize:
LOW Latch ' make output and keep low
pattern = %00000001
Go_Forward:
GOSUB Out_595
PAUSE DelayTime ' put pattern on 74x595
pattern = pattern << 1 ' shift pattern to the left
IF (pattern = %10000000) THEN Go_Reverse ' test for final position
GOTO Go_Forward ' continue in this direction
Go_Reverse:
GOSUB Out_595
PAUSE DelayTime
pattern = pattern >> 1
IF (pattern = %00000001) THEN Go_Forward
GOTO Go_Reverse
Out_595:
SHIFTOUT DataOut, Clock, MSBFirst, [noparse][[/noparse]pattern] ' send pattern to 74x595
PULSOUT Latch, 5 ' latch outputs
RETURN
INCLUDE "modedefs.bas"
Clock CON 0 ' shift clock (74HC595.11)
DataOut CON 1 ' serial data out (74HC595.14)
Latch CON 2 ' output latch (74HC595.12)
DelayTime CON 100
pattern VAR Byte ' output pattern
Initialize:
LOW Latch ' make output and keep low
pattern = %00000001
Go_Forward:
GOSUB Out_595
PAUSE DelayTime ' put pattern on 74x595
pattern = pattern << 1 ' shift pattern to the left
IF (pattern = %10000000) THEN Go_Reverse ' test for final position
GOTO Go_Forward ' continue in this direction
Go_Reverse:
GOSUB Out_595
PAUSE DelayTime
pattern = pattern >> 1
IF (pattern = %00000001) THEN Go_Forward
GOTO Go_Reverse
Out_595:
SHIFTOUT DataOut, Clock, MSBFirst, [noparse][[/noparse]pattern] ' send pattern to 74x595
PULSOUT Latch, 5 ' latch outputs
RETURN
Comments
This should display the digits 0 to 9.
I haven't tested this and it's two in the morning so there could be errors but hopefully it will get you going.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows