BillyC1
Newbie level 3
Youtube:
https://www.youtube.com/watch?v=QiTiAgobUi4&index=2&list=PLv4o3YhlQJ0sRXgDI7IRO7GMVsycBilcEProton
Basic Code
Visual Basic Code
you can see the Attachment for more information;-)
https://www.youtube.com/watch?v=QiTiAgobUi4&index=2&list=PLv4o3YhlQJ0sRXgDI7IRO7GMVsycBilcEProton
Basic Code
Code:
Device=16F628A
Xtal=20
All_Digital true
Hserial_Baud 9600 ' Setting Baud rate
TXSTA.5=1 ' setting Transmit Enable Bit
RCSTA.7=1
RCSTA.4=1
RX VAR PORTB.1
TX VAR PORTB.2
'--------------------------------------------'
'Ports for LED indicator if they are ON/OFF
Output PORTA.0
Output PORTA.1
Output PORTA.2
Output PORTA.3
'Ports that will switch the Relays
Output PORTB.0
Output PORTB.3
Output PORTB.4
Output PORTB.5
'--------------------------------------------'
'Symbol for LED indicator If they are On/OFF
Symbol led0 PORTA.0
Symbol led1 PORTA.1
Symbol led2 PORTA.2
Symbol led3 PORTA.3
'Symbol for Ports that will switch the Relays
Symbol led00 PORTB.0
Symbol led11 PORTB.3
Symbol led22 PORTB.4
Symbol led33 PORTB.5
'--------------------------------------------'
'Low led state at default start of the program
Low led0
Low led1
Low led2
Low led3
Dim x As Byte
loop:
'x for getting the serial
x = HRSIn
'LED1
If x = "A" Then
High led00 'Switch ON Relay1 or PortB0 if serial = A
DelayMS 1000 'Delay 1 second
High led0 'Turn ON Led 1 indicator Relay 1 is ON
ElseIf x = "B" Then
Low led00 'Switch OFF Relay1 or PortB0 if serial = B
DelayMS 1000 'Delay 1 second
Low led0 'Turn OFF Led 1 indicator Relay 1 is OFF
EndIf
'LED2
If x = "C" Then
High led11
DelayMS 1000
High led1
ElseIf x = "D" Then
Low led11
DelayMS 1000
Low led1
EndIf
'LED3
If x = "E" Then
High led22
DelayMS 1000
High led2
ElseIf x = "F" Then
Low led22
DelayMS 1000
Low led2
EndIf
'LED4
If x = "G" Then
High led33
DelayMS 1000
High led3
ElseIf x = "H" Then
Low led33
DelayMS 1000
Low led3
EndIf
GoTo loop
End
Visual Basic Code
Code:
Imports System
Imports System.IO
Imports System.IO.Ports
Imports System.Threading
Imports System.ComponentModel
Public Class Automation
Private Sub Automation_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
RS232.Close()
RS232.PortName = "com11" 'change com port to match your Arduino port
RS232.BaudRate = 9600
RS232.DataBits = 8
RS232.Parity = Parity.None
RS232.StopBits = StopBits.One
RS232.Handshake = Handshake.None
RS232.Encoding = System.Text.Encoding.Default 'very important!
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
RS232.Open()
RS232.Write("A")
RS232.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
RS232.Open()
RS232.Write("B")
RS232.Close()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
RS232.Open()
RS232.Write("C")
RS232.Close()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
RS232.Open()
RS232.Write("D")
RS232.Close()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
RS232.Open()
RS232.Write("E")
RS232.Close()
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
RS232.Open()
RS232.Write("F")
RS232.Close()
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
RS232.Open()
RS232.Write("G")
RS232.Close()
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
RS232.Open()
RS232.Write("H")
RS232.Close()
End Sub
End Class
you can see the Attachment for more information;-)