I have problems to turn on a led with arduino, you have to turn on the led when the user enters a "1" and show a legend that says "led on from the computer" and it has to be turned off when the user enters a " 0 "and show a legend that says" led off from computer ", also must turn on with bluethooth from the mobile. Could you please help me?
#include <SoftwareSerial.h>
SoftwareSerial BT1(2,3);
int myLed= 12;
char s ='0';
int g = 0;
void setup() {
Serial.println("LISTO :)");
BT1.begin(9600);
pinMode(myLed,OUTPUT);
}
void loop() {
if(BT1.available()){
Serial.println("SI ESTA LISTO");
g=BT1.read();
Serial.println(g);
}
if(g==49){
digitalWrite(myLed,HIGH);
Serial.println("led enciende desde celular");
g=50;
}
if(g==48){
digitalWrite(myLed,LOW);
Serial.println("led apaga desde celular");
g=47;
}
if(s=='1'){
digitalWrite(myLed,HIGH);
Serial.println("led enciende desde computadora");
}
}