String stringOne,
stringTwo, stringThree;
//Initialisation des E/S et communication
void setup() {
Serial.begin(9600); //vitesse de transmission
Serial1.begin(9600); // liaison BT vers
android
pinMode(LED_PIN13,OUTPUT)
;
pinMode(LED_PIN8,OUTPUT)
;
pinMode(LED_PIN9,OUTPUT)
;
stringOne =
String("You added ");
stringTwo =
String("this string");
stringThree =
String();
//setupmyBlueToothConnection(); // appel de la
fonction de configuration du module bluetooth si nécessaire
}
void loop() {
recevoir1();
// 1x = SMS pour carte BT // 2x = SMS pour carte Hangar // 3x = SMS pour carte DOMO
if
(w==11) { reponse=11;
delay (100); envoyer1();
digitalWrite(LED_PIN8,HIGH);
}
else {
digitalWrite(LED_PIN8,LOW); }
if
(w==12) { reponse=12; delay (100); envoyer1();
digitalWrite(LED_PIN9,HIGH);
}
if
(w==13) { reponse=13; delay (100); envoyer1(); digitalWrite(LED_PIN8,HIGH); }
stringOne =
"Sensor value: ";
stringTwo = " ";
//stringThree = stringOne + t1 + stringTwo + t2 + stringTwo + t3 +
stringTwo + t4;
}
//voids reception pour serial 1 2 et 3 de la
carte BT
void
recevoir1(){ if (Serial1.available()) { w=
Serial1.read(); Serial.print("recevoir1:"); Serial.println(w);
Serial1.flush(); } }
//voids envoi pour serial 1 2 et 3 de la carte
BT
void
envoyer1() { Serial1.print(stringThree);
Serial.print("envoi 1:"); Serial.println(stringThree); Serial1.flush(); }
void
setupmyBlueToothConnection() { // configuration du module bluetooth
Serial.begin(9600);
// set BluetoothBee BaudRate to default baud rate 38400
Serial.print("∖r∖n+STWMOD=0∖r∖n");
// set the bluetooth work in slave mode
Serial.print("∖r∖n+STNA=BTSlave_1∖r∖n");
// set the bluetooth name as "BTSlave_1"
Serial.print("∖r∖n+STOAUT=1∖r∖n");
// permit Paired device to connect me
Serial.print("∖r∖n+STAUTO=0∖r∖n");
// auto-connection should be forbidden here
delay(2000);
// this delay is required.
Serial.print("∖r∖n+INQ=1∖r∖n");
// make the slave bluetooth inquirable
Serial.println("Le module bluetooth est
interrogeable!"); // affichage dans le moniteur série
delay(2000);
// this delay is required.
Serial.flush();
}
//The end