chr
01-22-2008, 10:26 AM
Greetings to all, I am having small issues with a Visual Basic 6 code I am working on to widen my knowledge. I'm new to the programming scene, hopefully someone here will be able to help.
I'll be lighting up LED lights via Parallel Port. My code is written in Vb6. I'm using the inpout32.dll to send my signals to the pins. I am using a breadboard to establish the circuit. Basically what I am having trouble is to code a counter that can count how many times the LED light is blinking. I have little knowledge about Timers, everything I read about it isn't really helping me. I'll paste my code down here and try and explain it as well as I can in English.
MAIN PROBLEM : Coding a counter that can detect how many times the LED light blinks in real time. I know how to make the light stop blinking after X amount of seconds, that's simple to do. I am just lost on how to be able to make the counter detect how many times it's actually blinking in real time.
Private Declare Function Inp Lib "inpout32.dll" _
Alias "Inp32" (ByVal sgnGo As Integer) As Integer
Private Declare Sub Out Lib "inpout32.dll" _
Alias "Out32" (ByVal sgnGo As Integer, ByVal Value As Integer)
'Variable to send the signals to the pins
Dim sgnGo As String 'Variable to send the single
Dim onOff as Long 'Variable to make the LED blink on/off
'The HEX code for the LPT1 port defined in form_load
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
Timer2.Enabled = False
Timer2.Interval = 2000
sgnGo = &H378
End Sub
'Out is to simply send the signal to the pin using inpout32.dll
Private Sub pn1_Click()
Timer1.Enabled = True
Timer2.Enabled = False
Out sgnGo, 1
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = True
Timer2.Enabled = False
onOff = onOff Xor 1 'Light blinks on/off every 1 second
Out sgnGo, onOff
End Sub
Private Sub pn2_Click()
Timer2.Enabled = True
Timer1.Enabled = False
Out sgnGo, 2
End Sub
Private Sub Timer2_Timer()
Timer2.Enabled = True
Timer1.Enabled = False
onOff = onOff Xor 2 'Light blinks on/off every 2 seconds
Out sgnGo, onOff
End Sub
'Procedure to turn off LED lights
Private Sub sgnArret_Click()
Timer1.Enabled = False
Timer2.Enabled = False
Out sgnGo, 0
End Sub
I'll be lighting up LED lights via Parallel Port. My code is written in Vb6. I'm using the inpout32.dll to send my signals to the pins. I am using a breadboard to establish the circuit. Basically what I am having trouble is to code a counter that can count how many times the LED light is blinking. I have little knowledge about Timers, everything I read about it isn't really helping me. I'll paste my code down here and try and explain it as well as I can in English.
MAIN PROBLEM : Coding a counter that can detect how many times the LED light blinks in real time. I know how to make the light stop blinking after X amount of seconds, that's simple to do. I am just lost on how to be able to make the counter detect how many times it's actually blinking in real time.
Private Declare Function Inp Lib "inpout32.dll" _
Alias "Inp32" (ByVal sgnGo As Integer) As Integer
Private Declare Sub Out Lib "inpout32.dll" _
Alias "Out32" (ByVal sgnGo As Integer, ByVal Value As Integer)
'Variable to send the signals to the pins
Dim sgnGo As String 'Variable to send the single
Dim onOff as Long 'Variable to make the LED blink on/off
'The HEX code for the LPT1 port defined in form_load
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
Timer2.Enabled = False
Timer2.Interval = 2000
sgnGo = &H378
End Sub
'Out is to simply send the signal to the pin using inpout32.dll
Private Sub pn1_Click()
Timer1.Enabled = True
Timer2.Enabled = False
Out sgnGo, 1
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = True
Timer2.Enabled = False
onOff = onOff Xor 1 'Light blinks on/off every 1 second
Out sgnGo, onOff
End Sub
Private Sub pn2_Click()
Timer2.Enabled = True
Timer1.Enabled = False
Out sgnGo, 2
End Sub
Private Sub Timer2_Timer()
Timer2.Enabled = True
Timer1.Enabled = False
onOff = onOff Xor 2 'Light blinks on/off every 2 seconds
Out sgnGo, onOff
End Sub
'Procedure to turn off LED lights
Private Sub sgnArret_Click()
Timer1.Enabled = False
Timer2.Enabled = False
Out sgnGo, 0
End Sub