SparkFun Forums 

Where electronics enthusiasts find answers.

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!
By felipeunix
#191451
Only a brief test with the code below, it works perfectly.

Upon receiving "a", the LED is turned on.

But this only works if you are with IDE Arduino open. If closed, or only with the powered circuit can connect through the phone, but does not seem to correctly recognize the commands. :roll:

what am I doing wrong :?:

*Through AT commands, baud is set to 38400.
Code: Select all
char aux = 0;
int led = 17;
void setup() {
  Serial1.begin(38400);
  while (!Serial1);
  pinMode(led, OUTPUT);
  digitalWrite(led, HIGH);
}
void loop() {
  if (Serial1.available()) {
    aux = (char) Serial1.read();
    delay(100);   
    if (aux == 'a') {
      digitalWrite(led, LOW);
    } else {
      digitalWrite(led, HIGH);
    }
  }
  delay(100);
}