A
AshBasher
Guest
Hi there, I am very new to Vb and have made a device to switch on my 5 heaters at different intervals. However, when I make the arguments in Vb to send to the serial port for all heaters to turn on at the same time, only one heater(usually the last one) actually turns on. I think it is a timing error and the code is completely missing preceding commands. I would really appreciate help but as I say, I am really new to this. I am using (TimeOfDay) and comparing a textbox (which I set on the screen to a pre determined time) and whether a panel is yellow or not(also set on the screen) to send a message to the serial port. When one of the compare/yellow box and correct time is used, it ouputs to the serial port but... if I turn on all the yellow boxes, when the curent time lines up with the active boxes etc. only the last activated serial port message is sent (ie) if I set 2 and 3, only three works or if I set 1 and 5, only 5 works.[ code ]
Private Sub HeaterClockTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HeaterClockTimer.Tick
TimeBox.Text = CStr(TimeOfDay)
If CStr(TimeOfDay) = OnTimeLabel1.Text And Panel3.BackColor = Color.Yellow Then
SerialPort1.WriteLine("T1" + ControlChars.CrLf)
End If
If CStr(TimeOfDay) = OnTimeLabel1.Text And Panel1.BackColor = Color.Yellow Then
SerialPort1.WriteLine("T2" + ControlChars.CrLf)
End If
If CStr(TimeOfDay) = OnTimeLabel1.Text And Panel5.BackColor = Color.Yellow Then
SerialPort1.WriteLine("T3" + ControlChars.CrLf)
End If
If CStr(TimeOfDay) = OnTimeLabel1.Text And Panel7.BackColor = Color.Yellow Then
SerialPort1.WriteLine("T4" + ControlChars.CrLf)
End If
If CStr(TimeOfDay) = OnTimeLabel1.Text And Panel6.BackColor = Color.Yellow Then
SerialPort1.WriteLine("T5" + ControlChars.CrLf)
End If
End Sub
[ /code ]
Continue reading...
Private Sub HeaterClockTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HeaterClockTimer.Tick
TimeBox.Text = CStr(TimeOfDay)
If CStr(TimeOfDay) = OnTimeLabel1.Text And Panel3.BackColor = Color.Yellow Then
SerialPort1.WriteLine("T1" + ControlChars.CrLf)
End If
If CStr(TimeOfDay) = OnTimeLabel1.Text And Panel1.BackColor = Color.Yellow Then
SerialPort1.WriteLine("T2" + ControlChars.CrLf)
End If
If CStr(TimeOfDay) = OnTimeLabel1.Text And Panel5.BackColor = Color.Yellow Then
SerialPort1.WriteLine("T3" + ControlChars.CrLf)
End If
If CStr(TimeOfDay) = OnTimeLabel1.Text And Panel7.BackColor = Color.Yellow Then
SerialPort1.WriteLine("T4" + ControlChars.CrLf)
End If
If CStr(TimeOfDay) = OnTimeLabel1.Text And Panel6.BackColor = Color.Yellow Then
SerialPort1.WriteLine("T5" + ControlChars.CrLf)
End If
End Sub
[ /code ]
Continue reading...