Un collectif d'hélicoptère contrôle l'angle des pales.
Voici un montage permettant d'avoir un collectif USB en complément d'un joystick classique qui servira pour le cyclique.
Buts :
Un teensy++ 2.0 compatible Arduino :
Programme :
#include <Bounce.h> Bounce button0 = Bounce(0, 10); // 10 ms debounce time Bounce button1 = Bounce(1, 10); Bounce button2 = Bounce(2, 10); Bounce button3 = Bounce(3, 10); Bounce button4 = Bounce(4, 10); Bounce button5 = Bounce(5, 10); Bounce button6 = Bounce(6, 10); Bounce button7 = Bounce(7, 10); void setup() { pinMode(0, INPUT_PULLUP); pinMode(1, INPUT_PULLUP); pinMode(2, INPUT_PULLUP); pinMode(3, INPUT_PULLUP); pinMode(4, INPUT_PULLUP); pinMode(5, INPUT_PULLUP); pinMode(6, INPUT_PULLUP); pinMode(7, INPUT_PULLUP); } void loop() { Joystick.Z(analogRead(0)); // collectif Joystick.Zrotate(analogRead(1)); // potentiomètre de manche Joystick.X(analogRead(2)); // mini stick X Joystick.Y(analogRead(3)); // mini stick Y button0.update(); button1.update(); button2.update(); button3.update(); button4.update(); button5.update(); button6.update(); button7.update(); if (button0.fallingEdge()) { Joystick.button(1, 1); } if (button1.fallingEdge()) { Joystick.button(2, 1); } if (button2.fallingEdge()) { Joystick.button(3, 1); } if (button3.fallingEdge()) { Joystick.button(4, 1); } if (button4.fallingEdge()) { Joystick.button(5, 1); } if (button5.fallingEdge()) { Joystick.button(6, 1); } if (button6.fallingEdge()) { Joystick.button(7, 1); } if (button7.fallingEdge()) { Joystick.button(8, 1); } if (button0.risingEdge()) { Joystick.button(1, 0); } if (button1.risingEdge()) { Joystick.button(2, 0); } if (button2.risingEdge()) { Joystick.button(3, 0); } if (button3.risingEdge()) { Joystick.button(4, 0); } if (button4.risingEdge()) { Joystick.button(5, 0); } if (button5.risingEdge()) { Joystick.button(6, 0); } if (button6.risingEdge()) { Joystick.button(7, 0); } if (button7.risingEdge()) { Joystick.button(8, 0); } delay(50); }