I am confused a bit. I have written the VB code to make ON and OFF the LED connected to Arduino. I am sending data from VB app over COM port (instead of serial monitor) and the data is '1' for LED ON and '0' for OFF. Here I want to send this signal through RF-433 module. I have connected the TX pin of Arduino to Data pin of the RF module. On other hand, the second Arduino is connected to RF receiver with LED on Pin 12. Now I am not getting how to write code for Arduino of TX side to send data through RF? I mean if I use serial monitor to send data, then Serial.available()
and Serial.read()
can be used to send data over serial monitor with help of keyboard, but here I am sending that data from VB app. So what is the code for Arduino to activate RF TX connected on TX pin of Arduino?
Here is my VB code:
Imports System.IO
Imports System.IO.Ports
Imports System.Threading
Public Class Form1
Shared _continue As Boolean
Shared _serialPort As SerialPort
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SerialPort1.Close()
SerialPort1.PortName = "com12" 'change com port to match your Arduino port
SerialPort1.BaudRate = 9600
SerialPort1.DataBits = 8
SerialPort1.Parity = Parity.None
SerialPort1.StopBits = StopBits.One
SerialPort1.Handshake = Handshake.None
SerialPort1.Encoding = System.Text.Encoding.Default 'very important!
End Sub
Private Sub btnOn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOn.Click
picOn.Visible = True
SerialPort1.Open()
SerialPort1.Write("1")
SerialPort1.Close()
End Sub
Private Sub btnOff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOff.Click
picOn.Visible = False
SerialPort1.Open()
SerialPort1.Write("0")
SerialPort1.Close()
End Sub
End Class