Please help me.
I dont know how/why I can't make the picture box show.
VB.NET Code:
Imports System.IO
Imports System.IO.Ports
Imports System.Threading
Public Class Form1
Dim WithEvents SerialPort1 As New IO.Ports.SerialPort
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
SerialPort1.PortName = "COM4"
SerialPort1.BaudRate = 38400
SerialPort1.Parity = Parity.None
SerialPort1.DataBits = 8
SerialPort1.StopBits = StopBits.One
SerialPort1.DtrEnable = False
SerialPort1.ReceivedBytesThreshold = 3
SerialPort1.Open()
End Sub
Dim temblin As String
Private Sub Serial_Port1_Datareceived(ByVal sender As Object, ByVal e As EventArgs) Handles SerialPort1.DataReceived
temblin = SerialPort1.ReadLine
Me.Invoke(New EventHandler(AddressOf DoUpdate))
End Sub
Public Sub DoUpdate()
'Lot1
TextBox1.Text = temblin
If temblin = "a" Then
PictureBox1.Show()
ElseIf temblin = "b" Then
PictureBox1.Show()
End If
End Sub
End Class
Arduino code:
char Rx_data[50];
unsigned char Rx_index = 0;
int i = 0;
char msg[160];
int sig;
const int buttonPin = 2;
const int buttonPin1 = 4;
const int buttonPin2 = 6;
const int ledPin = 12;// the number of the pushbutton pin
const int ledPin1 = 13;
const int ledPin2 = 11;
const int buzzerPin = 8;
// the number of the LED pin
// variables will change:
int buttonState = 0;
int buttonState2 = 0;// variable for reading the pushbutton status
int buttonState3 = 0;
int newState = 0;
void setup() {
Serial.begin(38400);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(buzzerPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT_PULLUP);
pinMode(buttonPin1, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH && buttonState2 == LOW) {
// turn LED on:
digitalWrite(ledPin, HIGH);
SendTextMessage();
Serial.println("a");
delay(150);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
buttonState2 = digitalRead(buttonPin1);
if (buttonState2 == HIGH && buttonState3 == LOW) {
// turn LED on:
digitalWrite(ledPin1, HIGH);
SendTextMessage();
Serial.println("b");
delay(150);
}
else {
// turn LED off:
digitalWrite(ledPin1, LOW);
}
buttonState3 = digitalRead(buttonPin2);
if (buttonState3 == HIGH) {
// turn LED on:
digitalWrite(ledPin2, HIGH);
digitalWrite(buzzerPin, HIGH);
SendTextMessage();
Serial.println("c");
delay(150);
}
else {
// turn LED off:
digitalWrite(ledPin2, LOW);
digitalWrite(buzzerPin, LOW);
}
}
//**********************************************************
void SendTextMessage()
{
Serial.print("AT+CMGF=1\r");
delay(100);
Serial.println("AT + CMGS = \"09108690901\"");
delay(100);
Serial.println("Warning");
delay(100);
Serial.println((char)26);
delay(100);
Serial.println();
}