B4R Question a problem using IC 74HC595 with 7 segments

vali khandangoll

Active Member
hi all of you.
i want to use a 7 segment with IC 74HC595.
Everything works fine when I replace the LED and 7 segment.
but when i use 7 segment does not work Properly.
my code is below

Sub Process_Globals
Public Serial1 As Serial
Private datapin, latchpin, clockpin As Pin
Private Registers(8) As Boolean
End Sub

Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")

datapin.Initialize(8, datapin.MODE_OUTPUT)
latchpin.Initialize(9, latchpin.MODE_OUTPUT)
clockpin.Initialize(10, clockpin.MODE_OUTPUT)

Delay(3000)
Dim j As Int
Do While 1=1
For j=0 To 7
' LED is turning on
Registers(j) = True
UpdateRegister(j)
Delay(1000)
Next

'LED is turrning off
For j=0 To 7
Registers(j) = False
UpdateRegister(j)
Delay(1000)
Next
Loop

Log("Finished")
End Sub

Private Sub UpdateRegister(segment_no)
latchpin.DigitalWrite(False)

clockpin.DigitalWrite(False)
datapin.DigitalWrite(Registers(segment_no))
Delay(10)
clockpin.DigitalWrite(True)
Delay(10)


latchpin.DigitalWrite(True)
Delay(1)
End Sub
 

Attachments

  • 1635618587350.png
    1635618587350.png
    316.1 KB · Views: 148
  • bPD5g.jpg
    bPD5g.jpg
    230.5 KB · Views: 148

janderkan

Well-Known Member
Licensed User
Longtime User
Could you tell us what is not working ?

You never exit the first loop, is that the error ?
B4X:
Do While 1=1

Using delays is always an error.
 
Upvote 0

vali khandangoll

Active Member
Could you tell us what is not working ?

You never exit the first loop, is that the error ?
B4X:
Do While 1=1

Using delays is always an error.
Hi
This loop was created just to test the LEDes.

I mean, the LEDs come on in order, but the segments in 7 segment do not come in

1635703409946.png

this system is work currectly but 7 segment is not
 
Upvote 0
Top