const int threhold = 100; int sensorReading; int irs=0; void setup() { pinMode(irs, INPUT); Serial.begin(9600); } void loop() { sensorReading = analogRead(irs); if(sensorReading > threhold) { Serial.write("1"); } else { Serial.write("0"); } delay(100); }
Imports System.IO Imports System.IO.Ports Dim val As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load SerialPort1.Encoding = System.Text.Encoding.Default SerialPort1.Open() val = SerialPort1.ReadLine If val = 0 Then PictureBox1.Image = My.Resources.Button_Blank_Red_icon__1_ ElseIf val = 1 Then PictureBox1.Image = My.Resources.Button_Blank_Green_icon_2 End If End Sub
Arduino
VB
Serial.Write(1)
if str = "0"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)