Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
|
inmoov:arduino [2017/02/28 15:32] plguen |
inmoov:arduino [2018/05/02 07:11] (Version actuelle) |
||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| ==== Code Arduino ==== | ==== Code Arduino ==== | ||
| + | == Main == | ||
| <code> | <code> | ||
| Ligne 142: | Ligne 143: | ||
| </code> | </code> | ||
| + | == Nunchuck == | ||
| + | |||
| + | <code> | ||
| + | /* | ||
| + | * ArduinoNunchukDemo.ino | ||
| + | * | ||
| + | * Copyright 2011-2013 Gabriel Bianconi, http://www.gabrielbianconi.com/ | ||
| + | * | ||
| + | * Project URL: http://www.gabrielbianconi.com/projects/arduinonunchuk/ | ||
| + | * | ||
| + | */ | ||
| + | //Bibliothèques | ||
| + | #include "Servo.h" | ||
| + | #include <Wire.h> | ||
| + | #include <ArduinoNunchuk.h> | ||
| + | |||
| + | #define BAUDRATE 19200 | ||
| + | |||
| + | ArduinoNunchuk nunchuk = ArduinoNunchuk(); | ||
| + | int joyX,joyY; | ||
| + | |||
| + | //Servo du bas : | ||
| + | Servo servoBas; | ||
| + | int pinServoBas = 9; | ||
| + | int servoBasInit = 90; | ||
| + | |||
| + | void setup() | ||
| + | { | ||
| + | | ||
| + | //Initialisation des servos : | ||
| + | servoBas.attach(pinServoBas); | ||
| + | servoBas.write(servoBasInit); | ||
| + | | ||
| + | Serial.begin(BAUDRATE); | ||
| + | nunchuk.init(); | ||
| + | } | ||
| + | |||
| + | void loop() | ||
| + | { | ||
| + | nunchuk.update(); | ||
| + | |||
| + | //Joystick Y (nommé joyY) -> Servo bas | ||
| + | joyX = nunchuk.analogX, DEC; | ||
| + | Serial.println(joyX); | ||
| + | joyX = map(joyX, 220, 30, 0, 180); | ||
| + | servoBas.write(joyX); | ||
| + | Serial.print(joyX); | ||
| + | Serial.print(' '); | ||
| + | delay(100); | ||
| + | } | ||
| + | </code> | ||
| ==== Liens Arduino ==== | ==== Liens Arduino ==== | ||
| Ligne 149: | Ligne 201: | ||
| http://tiptopboards.free.fr/arduino_forum/viewtopic.php?f=2&t=2 | http://tiptopboards.free.fr/arduino_forum/viewtopic.php?f=2&t=2 | ||
| + | |||
| + | https://create.arduino.cc/projecthub/infusion/using-a-wii-nunchuk-with-arduino-597254 | ||
| + | |||
| + | http://www.robot-maker.com/forum/blog/62/entry-57-utiliser-une-nunchuk/ | ||
| + | |||
| + | https://www.skitoo.net/tutoriel-arduino-comment-controler-un-servomoteur-avec-un-nunchuck-de-wii/ | ||
| + | |||
| + | |||
| + | http://quai-lab.com/utilisation-snap4arduino-en-robotique-educative-animer-main-du-robot-humanoide-inmoov/ | ||