/* Bluetooth_led is to control a led from an application */ #define led 7 // pins affectation #define RX 2 #define TX 3 word received_byte; // word that receive emitted data // Création d'une liaison série #include SoftwareSerial bluetooth(RX,TX); void setup() { Serial.begin(9600); // serial initialisation @ 9600 bauds bluetooth.begin(9600); // Bluetooth serial connexion initialisation @ 9600 bauds pinMode(led,OUTPUT) ; // led pin as output } void loop() { ReceiveData(); // call ReceiveData() function if (received_byte==49) // if received byte is 1 (49 is ASCII code for 1) { Serial.println("Led ON"); digitalWrite(led,HIGH); } if (received_byte==48) // if received byte is 0 (48 is ASCII code for 0) { Serial.println("Led OFF"); digitalWrite(led,LOW); } delay(200); } //procédure qui lit les trames de la tablette void ReceiveData() { if (bluetooth.available()) { received_byte=bluetooth.read(); } }