Arduino + HC-05 + Fritzing

#define ledPin 13
int blueChar = 0;
void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
Serial.begin(9600); // Default communication rate of the Bluetooth module
}
void loop() {
if(Serial.available() > 0){ // Checks whether data is comming from the serial port
blueChar = Serial.read(); // Reads the data from the serial port
}
switch (blueChar) {
case ‘0’:
digitalWrite(ledPin, LOW); // Turn LED OFF
// Serial.println(“LED: OFF”); // Send back, to the phone, the String “LED: ON”
//state = ‘0’;
break;
case ‘1’:
digitalWrite(ledPin, HIGH);
//Serial.println(“LED: ON”);;
//state = ‘1’;
break;
case ‘a’:
Serial.println(‘a’);
digitalWrite(13, HIGH);
break;
case ‘b’:
Serial.println(‘b’);
digitalWrite(13, LOW);
break;
case ‘c’:
Serial.println(‘c’);
break;
case ‘d’:
Serial.println(‘d’);
break;

}
blueChar=’ ‘;
}

 

Deixe um comentário

O seu endereço de email não será publicado. Campos obrigatórios marcados com *