Arduino Pro Micro (ATMega32u4) with Bluetooth HC-05


only brief test code below, works perfectly.
upon receiving "a", led turned on.
but works if ide arduino open. if closed, or powered circuit can connect through phone, not seem correctly recognize commands.

what doing wrong? :(

*through @ commands, baud set 38400.

code: [select]
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);
}



skip the 
code: [select]
while (!serial1);

it needed if using serial in ide monitor.


Arduino Forum > Using Arduino > Programming Questions > Arduino Pro Micro (ATMega32u4) with Bluetooth HC-05


arduino

Comments

Popular posts from this blog

Valutazione Template - Joomla! Forum - community, help and support

SD Datastring Convention

First use of Arduino Uno : avrdude error on Blink uploading