tel0026
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédenteProchaine révisionLes deux révisions suivantes | ||
tel0026 [2017/04/28 12:35] – [Commande (master)] simon | tel0026 [2017/05/07 14:15] – simon | ||
---|---|---|---|
Ligne 202: | Ligne 202: | ||
==== Programmes Arduino ==== | ==== Programmes Arduino ==== | ||
+ | Maintenant que nous avons configurés deux modules pour qu'ils se connectent ensemble, nous pouvons les utiliser chacun sur une Arduino et faire communiquer les deux Arduino ensemble. | ||
+ | |||
+ | * [[allumer une led via bluetooth]] | ||
+ | * [[Gestion de 3 leds via bluetooth]] | ||
+ | |||
+ | === Mise en place === | ||
+ | * Arduino " | ||
+ | * Une [[https:// | ||
+ | * Avec un [[https:// | ||
+ | * Sur lequel on met un [[https:// | ||
+ | |||
+ | * Arduino " | ||
+ | * Une [[https:// | ||
+ | * Avec un [[https:// | ||
+ | * Sur lequel on met une [[https:// | ||
+ | |||
+ | <WRAP center round important 60%> | ||
+ | **TODO:** Ajouter photos! | ||
+ | </ | ||
+ | |||
+ | === Programme " | ||
+ | <code c> | ||
+ | /* Minimal code for testing bluetooth module TEL0026 with a button | ||
+ | |||
+ | This program must be used with " | ||
+ | |||
+ | The circuit is based on Dreamer Nano V4.1, compatible Arduino Leonardo ( https:// | ||
+ | TEL0026 and button are plugged on Nano I/O Shield ( https:// | ||
+ | |||
+ | Created 2017 by Simon Lefort. | ||
+ | */ | ||
+ | |||
+ | int buttonPin = 8; //button is on pin 8 | ||
+ | |||
+ | void setup() { | ||
+ | Serial.begin(38400); | ||
+ | Serial1.begin(38400); | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | int val = digitalRead(buttonPin); | ||
+ | delay(50); | ||
+ | | ||
+ | if (val == HIGH) { | ||
+ | Serial1.print(" | ||
+ | // | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | // | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === Programme " | ||
+ | <code c> | ||
+ | /* Minimal code for testing bluetooth module TEL0026 with a led. | ||
+ | If we received " | ||
+ | |||
+ | This program must be used with " | ||
+ | |||
+ | The circuit is based on Dreamer Nano V4.1, compatible Arduino Leonardo ( https:// | ||
+ | TEL0026 and button are plugged on Nano I/O Shield ( https:// | ||
+ | |||
+ | Created 2017 by Simon Lefort. | ||
+ | */ | ||
+ | |||
+ | int ledPin = 14; | ||
+ | int incomingByte = 0; | ||
+ | |||
+ | void setup() { | ||
+ | Serial.begin(38400); | ||
+ | Serial1.begin(38400); | ||
+ | | ||
+ | digitalWrite(ledPin, | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | if (Serial1.available() > 0){ | ||
+ | incomingByte = Serial1.read(); | ||
+ | | ||
+ | Serial.print(" | ||
+ | Serial.println(incomingByte); | ||
+ | | ||
+ | if (incomingByte = ' | ||
+ | digitalWrite(ledPin, | ||
+ | delay(500); | ||
+ | } | ||
+ | } | ||
+ | else{ | ||
+ | Serial.println(" | ||
+ | digitalWrite(ledPin, | ||
+ | delay(500); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === Remarques === | ||
+ | Ça marche mais j'ai des soucis si je laisse le bouton appuyé. Ça envoie une série de caractères et le " | ||
+ | |||
+ | |||
===== Sources ===== | ===== Sources ===== | ||
* [[https:// | * [[https:// | ||
* [[http:// | * [[http:// | ||
* [[https:// | * [[https:// |
tel0026.txt · Dernière modification : 2020/08/09 13:03 de 127.0.0.1