Outils pour utilisateurs

Outils du site


tel0026

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
tel0026 [2017/05/07 14:15] simontel0026 [2020/08/09 13:03] (Version actuelle) – modification externe 127.0.0.1
Ligne 206: Ligne 206:
   * [[allumer une led via bluetooth]]   * [[allumer une led via bluetooth]]
   * [[Gestion de 3 leds via bluetooth]]   * [[Gestion de 3 leds via bluetooth]]
- 
-=== Mise en place === 
-  * Arduino "master" 
-    * Une [[https://www.dfrobot.com/product-786.html|Dreamer Nano V4.1]] avec un ATmega32u4. 
-    * Avec un [[https://www.dfrobot.com/product-68.html|shield]]. 
-    * Sur lequel on met un [[https://www.dfrobot.com/product-360.html|TEL0026]] et un [[https://www.dfrobot.com/product-1098.html|bouton]] 
- 
-  * Arduino "slave" : 
-    * Une [[https://www.arduino.cc/en/Main/arduinoBoardMega2560|Arduino MEGA 2560]] 
-    * Avec un [[https://www.dfrobot.com/product-560.html|shield]] 
-    * Sur lequel on met une [[https://www.dfrobot.com/product-490.html|LED]] et on connecte un TEL0026. 
- 
-<WRAP center round important 60%> 
-**TODO:** Ajouter photos! 
-</WRAP> 
- 
-=== Programme "master" === 
-<code c> 
-/* Minimal code for testing bluetooth module TEL0026 with a button 
- 
-This program must be used with "bluetooth-TEL0026-robot-avec-led.ino". 
- 
-The circuit is based on Dreamer Nano V4.1, compatible Arduino Leonardo ( https://www.dfrobot.com/product-786.html ). 
-TEL0026 and button are plugged on Nano I/O Shield ( https://www.dfrobot.com/product-68.html ) 
-  
-Created 2017 by Simon Lefort. 
-*/ 
- 
-int buttonPin = 8; //button is on pin 8 
- 
-void setup() { 
-  Serial.begin(38400);   // Serial to talk with computer via USB 
-  Serial1.begin(38400);  // Serial to talk to bluetooth module TEL0026 
-} 
- 
-void loop() { 
-  int val = digitalRead(buttonPin); 
-  delay(50); 
-   
-  if (val == HIGH) { 
-    Serial1.print("b"); 
-    //Serial.println("push"); 
-  } 
-  else 
-  {  
-    //Serial.println("no push"); 
-  } 
-} 
-</code> 
- 
-=== Programme "slave" === 
-<code c> 
-/* Minimal code for testing bluetooth module TEL0026 with a led. 
-If we received "b1" by the bluetooth module, we light on the led. 
- 
-This program must be used with "bluetooth-TEL0026-commande-avec-bouton.ino". 
- 
-The circuit is based on Dreamer Nano V4.1, compatible Arduino Leonardo ( https://www.dfrobot.com/product-786.html ). 
-TEL0026 and button are plugged on Nano I/O Shield ( https://www.dfrobot.com/product-68.html ) 
-  
-Created 2017 by Simon Lefort. 
-*/ 
- 
-int ledPin = 14; 
-int incomingByte = 0; 
- 
-void setup() { 
-  Serial.begin(38400);  //communicate via USB 
-  Serial1.begin(38400); //communicate via Bluetooth 
-   
-  digitalWrite(ledPin, LOW); 
-} 
- 
-void loop() { 
-  if (Serial1.available() > 0){ 
-    incomingByte = Serial1.read(); 
-   
-    Serial.print("I received: "); 
-    Serial.println(incomingByte); 
-     
-    if (incomingByte = 'b'){ 
-      digitalWrite(ledPin, HIGH); 
-      delay(500); 
-    } 
-  } 
-  else{ 
-    Serial.println("nothing..."); 
-    digitalWrite(ledPin, LOW); 
-    delay(500); 
-  } 
-} 
-</code> 
- 
-=== Remarques === 
-Ça marche mais j'ai des soucis si je laisse le bouton appuyé. Ça envoie une série de caractères et le "slave" met un certain temps à la traiter. Il faut que je regarde comment améliorer ça très prochainement. 
- 
  
 ===== Sources ===== ===== Sources =====
tel0026.1494166557.txt.gz · Dernière modification : 2020/08/09 12:59 (modification externe)