xanseviera
Junior Member level 3
im doing simulation traffic light project using VB whereby hardware can be controlled by VB using serial port.
my project consist of 4 junction... any changes in VB can cause changes in my hardware as well.
im already program my PIC as follows:
Junction 1
"a"=green
"b"=yellow
"c"=red
Junction 2
"d"=green
"e"=yellow
"f"=red
Junction 3
"g"=green
"h"=yellow
"i"=red
Junction 4
"j"=green
"k"=yellow
"l"=red
"m"=all light turn off
Below is coding regarding my project...
can sum1 help me out..
TQ
my project consist of 4 junction... any changes in VB can cause changes in my hardware as well.
im already program my PIC as follows:
Junction 1
"a"=green
"b"=yellow
"c"=red
Junction 2
"d"=green
"e"=yellow
"f"=red
Junction 3
"g"=green
"h"=yellow
"i"=red
Junction 4
"j"=green
"k"=yellow
"l"=red
"m"=all light turn off
Below is coding regarding my project...
Code:
Private Sub LampuMerahNyala(Index As Integer)
Select Case Index
Case 0
MSComm1.Output = "c"
Case 1
MSComm1.Output = "f"
Case 2
MSComm1.Output = "i"
Case 3
MSComm1.Output = "l"
End Select
shpLampuMerah(Index).BackColor = vbRed
End Sub
Private Sub LampuMerahMati(Index As Integer)
Select Case Index
Case 0
MSComm1.Output = "m"
Case 1
MSComm1.Output = "m"
Case 2
MSComm1.Output = "m"
Case 3
MSComm1.Output = "m"
End Select
shpLampuMerah(Index).BackColor = RGB(50, 0, 0)
End Sub
Private Sub LampuKuningNyala(Index As Integer)
Select Case Index
Case 0
MSComm1.Output = "b"
Case 1
MSComm1.Output = "e"
Case 2
MSComm1.Output = "h"
Case 3
MSComm1.Output = "k"
End Select
shpLampuKuning(Index).BackColor = vbYellow
End Sub
Private Sub LampuKuningMati(Index As Integer)
Select Case Index
Case 0
MSComm1.Output = "m"
Case 1
MSComm1.Output = "m"
Case 2
MSComm1.Output = "m"
Case 3
MSComm1.Output = "m"
End Select
shpLampuKuning(Index).BackColor = RGB(50, 50, 0)
End Sub
Private Sub LampuHijauNyala(Index As Integer)
Select Case Index
Case 0
MSComm1.Output = "a"
idxLampuHijau = 0
Case 1
MSComm1.Output = "d"
idxLampuHijau = 1
Case 2
MSComm1.Output = "g"
idxLampuHijau = 2
Case 3
MSComm1.Output = "j"
idxLampuHijau = 3
End Select
shpLampuHijau(Index).BackColor = vbGreen
tmrArah.Enabled = True
End Sub
Private Sub LampuHijauMati(Index As Integer)
tmrArah.Enabled = False
ResetArahAnim
Select Case Index
Case 0
MSComm1.Output = "m"
Case 1
MSComm1.Output = "m"
Case 2
MSComm1.Output = "m"
Case 3
MSComm1.Output = "m"
End Select
shpLampuHijau(Index).BackColor = RGB(0, 50, 0)
End Sub
Private Sub tmrLampu_Timer()
Static Index As Integer
Static intLampu As Integer
Dim intNum As Integer
Select Case intLampu
Case 0 'Hijau
LampuMati
tmrLampu.Interval = Val(txtHijau(Index).Text) * 1000
LampuHijauNyala Index
For intNum = 0 To 3
If intNum <> Index Then LampuMerahNyala intNum
Next
intLampu = 1
Case 1 'Kuning
LampuMati
tmrLampu.Interval = 3000
LampuKuningNyala Index
For intNum = 0 To 3
If intNum <> Index Then LampuMerahNyala intNum
Next
intLampu = 0
Index = Index + 1
If Index = 4 Then Index = 0
End Select
End Sub
Private Sub cmdRun_Click(Index As Integer)
Dim intNum As Integer
LampuMati
tmrLampu.Interval = 1
tmrLampu.Enabled = True
' Fire Rx Event Every single Bytes
MSComm1.RThreshold = 1
' When Inputting Data, Input 1 Byte at a time
MSComm1.InputLen = 1
' 9600 Baud, No Parity, 8 Data Bits, 1 Stop Bit
MSComm1.Settings = "9600,N,8,1"
' Disable DTR
MSComm1.DTREnable = False
' Open COM3
MSComm1.CommPort = 3
MSComm1.PortOpen = True
End Sub
can sum1 help me out..
TQ