Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
openatelier:projet:telerobot [2021/05/18 17:15] emoc créée |
openatelier:projet:telerobot [2022/06/27 19:37] (Version actuelle) emoc |
||
---|---|---|---|
Ligne 9: | Ligne 9: | ||
Interface web : http://lesporteslogiques.net/telerobot/ | Interface web : http://lesporteslogiques.net/telerobot/ | ||
- | nb : 2 servomoteurs c'est trop de courant pour la broche ViN, solution élégante : en enlever un, ou ajouter une alim externe | + | ===== Étape 1 ===== |
- | Code photon | ||
- | <code> | + | |
+ | Code photon tout moche (adapté depuis https://github.com/lesporteslogiques/atelier_ioc_2017/tree/master/mouvement_photon%2Bservo ) | ||
+ | |||
+ | <accordion> | ||
+ | <panel title="telerobot_001.phot (cliquer pour afficher le code)"> | ||
+ | <code c telerobot_001.phot> | ||
#define broche_bouton1 D4 | #define broche_bouton1 D4 | ||
#define broche_bouton2 D5 | #define broche_bouton2 D5 | ||
Ligne 95: | Ligne 99: | ||
} | } | ||
</code> | </code> | ||
+ | |||
+ | </panel> | ||
+ | </accordion> | ||
+ | |||
+ | Peut-être remplacer par ce servo : https://www.dfrobot.com/product-1970.html \\ | ||
+ | Et puis ça ne marche pas, il reçoit une instruction par le web et plante avec D7 allumée fixe, peut-être que 2 moteurs c'est trop de courant pour la broche ViN, solution élégante : en enlever un, ou ajouter une alim externe | ||
+ | |||
+ | ===== Étape 2 ===== | ||
+ | |||
+ | À peine mieux, avec un seul servo, ça plante et se bloque aussi, alors trop de courant demandé ou autre raison ? Problème de servomoteur ? | ||
+ | |||
+ | <accordion> | ||
+ | <panel title="telerobot_002.phot (cliquer pour afficher le code)"> | ||
+ | <code c telerobot_002.phot> | ||
+ | #include <neopixel.h> // This #include statement was automatically added by the Particle IDE. | ||
+ | |||
+ | #define BROCHE_BOUTON1 D4 | ||
+ | #define BROCHE_BOUTON2 D5 | ||
+ | #define BROCHE_LED D2 | ||
+ | #define BROCHE_SERVO D0 | ||
+ | |||
+ | #define PIXEL_COUNT 4 | ||
+ | #define PIXEL_TYPE WS2812B | ||
+ | |||
+ | Adafruit_NeoPixel strip(PIXEL_COUNT, BROCHE_LED, PIXEL_TYPE); | ||
+ | |||
+ | Servo servo1; | ||
+ | Servo servo2; | ||
+ | |||
+ | int position = 0; | ||
+ | |||
+ | long compteur = 0; | ||
+ | long last_show = 0; | ||
+ | |||
+ | |||
+ | void setup() { | ||
+ | | ||
+ | //servo1.attach(BROCHE_SERVO); | ||
+ | //servo1.write(90); // test | ||
+ | |||
+ | pinMode(D7, OUTPUT); | ||
+ | pinMode(BROCHE_BOUTON1, INPUT); | ||
+ | pinMode(BROCHE_BOUTON2, INPUT); | ||
+ | | ||
+ | strip.begin(); | ||
+ | strip.show(); | ||
+ | | ||
+ | //Particle.function("alarme", declencherAlarme); | ||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | void loop() { | ||
+ | /* | ||
+ | if (digitalRead(BROCHE_BOUTON1) == HIGH) { | ||
+ | servo1.write(25); | ||
+ | digitalWrite(D7, HIGH); | ||
+ | delay(300); | ||
+ | servo1.write(90); | ||
+ | digitalWrite(D7, LOW); | ||
+ | delay(300); | ||
+ | }*/ | ||
+ | /* | ||
+ | if (digitalRead(BROCHE_BOUTON2) == HIGH) { | ||
+ | servo2.write(25); | ||
+ | digitalWrite(D7, HIGH); | ||
+ | delay(100); | ||
+ | servo2.write(90); | ||
+ | digitalWrite(D7, LOW); | ||
+ | delay(1000); | ||
+ | } */ | ||
+ | | ||
+ | | ||
+ | if (millis() - last_show > 1000) { | ||
+ | strip.setPixelColor(0, strip.Color(random(255), random(255), random(255))); | ||
+ | strip.setPixelColor(3, strip.Color(random(255), random(255), random(255))); | ||
+ | strip.setBrightness(200); | ||
+ | strip.show(); | ||
+ | last_show = millis(); | ||
+ | } | ||
+ | |||
+ | } | ||
+ | /* | ||
+ | int declencherAlarme(String commande) { | ||
+ | | ||
+ | if (commande == "m1gauche") { | ||
+ | | ||
+ | servo1.write(40); | ||
+ | digitalWrite(D7, HIGH); | ||
+ | delay(600); | ||
+ | servo1.write(90); | ||
+ | delay(600); | ||
+ | digitalWrite(D7, LOW); | ||
+ | |||
+ | } else if (commande == "m1droite") { | ||
+ | | ||
+ | servo1.write(140); | ||
+ | digitalWrite(D7, HIGH); | ||
+ | delay(600); | ||
+ | servo1.write(90); | ||
+ | delay(600); | ||
+ | digitalWrite(D7, LOW); | ||
+ | |||
+ | } | ||
+ | }*/ | ||
+ | </code> | ||
+ | </panel> | ||
+ | </accordion> | ||
+ | |||
+ | Petite amélioration quand même, il prend corps : avec des leds pour éclairer les yeux, et un système pour les faire bouger mais foutraque et en plus qui s'autodétruit assez vite. | ||
+ | |||
+ | {{:openatelier:projet:telerobot:protobot.jpg?direct&600|}} | ||
+ | |||
+ | Mais c'est quand même beaucoup plus joli que https://www.youtube.com/watch?v=XEDgSblMb_4 | ||
+ | |||
+ | ===== Étape 3 ===== | ||
+ | |||
+ | La prochaine, pour l'instant une todolist | ||
+ | * résoudre le problème principal | ||
+ | * des sourcils mobiles le rendraient beaucoup plus expressif | ||
+ | * cette bouche ne peut pas rester immobile | ||
+ | ===== Ressources ===== | ||
+ | |||
+ | photon datasheet : https://docs.particle.io/datasheets/wi-fi/photon-datasheet/ \\ | ||
+ | Intro générale au circuit Photon : https://github.com/emoc/photon_introduction \\ | ||
+ | |||
+ |