hi all
I have written the code blew in mikroBasic Pro to drive 4 seven segment
& it works well on Proteus the purpose of code is to make a counter from 0 to 9 on the 4 seven segment
but when i apply it on the real world it does not give me the expected result
also the seven segment are flickering all the time
note : My hardware is connected well & fully tested
is that code right ?
I have written the code blew in mikroBasic Pro to drive 4 seven segment
& it works well on Proteus the purpose of code is to make a counter from 0 to 9 on the 4 seven segment
but when i apply it on the real world it does not give me the expected result
also the seven segment are flickering all the time
note : My hardware is connected well & fully tested
is that code right ?
Rich (BB code):
program HC595
' Declarations section
'( 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 )
const AnodeNumbers as byte[10] = (0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90)
dim Datax as sbit at RB0_bit 'Data Input
dim Clk as sbit at RB1_bit 'clock
dim Latch as sbit at RB2_bit 'Latch
dim iLoop as byte
sub procedure ClockPuls()
Clk = 1
delay_us(5)
Clk = 0
end sub
sub procedure LatchPuls()
Latch = 1
delay_us(5)
Latch = 0
end sub
sub procedure ShiftOut(dim dgt as byte)
dim i as byte
dim RegCnt as byte
for RegCnt = 0 to 3'shift registers count (4 shift registers)
'-----------------------------------------------
for i = 0 to 7
if ((dgt<<i) AND 0x80) then
Datax = 1
else
Datax = 0
end if
ClockPuls
next i
LatchPuls
'-----------------------------------------------
next RegCnt
end sub
main:
' Main program
TRISB = 0
portb = 0
while 1
ShiftOut(%11111111)
Delay_Ms(5000)
for iLoop = 0 to 9
ShiftOut(AnodeNumbers[iLoop])
Delay_Ms(5000)
next iLoop
wend
end.