is there anyone who can help correct these codes?
Arduino code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(14, 15);
int led1 = 8;
int led2 = 9;
int led3 = 10;
int value = 0; //initial serial read value
void setup()
{
Serial.begin(9600); //this is important. the baud rate between arduino bluetooth and smartphone
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
}
void loop() {
while (mySerial.available())
{ //if serial reading is available
delay(1000); //delay for a second, avoid overloading
value = mySerial.read(); //value = serial value(led value)
Serial.print(value); //print the serial value
Serial.println();
if (value == 1) //the value which corresponds the MIT appinventor 2 byte sent. change accordingly to your own value here and MIT appinventor 2 code block
{
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
}
if (value == 2)
{
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, LOW);
}
if (value == 3)
{
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
}
}
}