Bonjour, j'ai besoin d'aide .
Je cherche a réaliser ce projet , mais je n'y arrive pas.
J'ai pris le code qu'il donne dans l'exemple ci-dessu mais il est pour une carte teensy et il me sort plusieurs erreurs que je n'arrive pas a corriger.
J'ai acheter la carte Micro Genuino
J'ai essayé différents branchement de fils, ainsi que différent code.
Je ne connais que très peu la programmation mais j'essai d'apprendre, j'ai essayé de prendre d'autres exemples mais il ne fonctionne pas.
Est-ce que quelqu'un peut m'aider.
Je n'ai pas tous mis du projet, seulement 5 switch on/off (toggle) et 2 on/off bouton pressoir.
pas de potentiomètre ni de led.
Le but est de construire un panel pour jouer avec un simulateur d'avion.
Voici le code qu'il suggère :
#include <Joystick.h>
Joystick_ Joystick;
/*
This code is for a teensy 3.1 used in my green russian control board
You must select the teensy board in Tools and change USB Type to Joystick
*/
//How many buttons I'm using, must equal amount of values in following array
#define NUM_BUTTONS 14
//Which pins I have attached to my buttons
int buttonList[NUM_BUTTONS] = {2,3,4,5,6,7,8,9,10,11,12,14,15,16};
//Led intensity, so super bright LEDS aren't shining in our eyes
#define INTENSITY 200
void setup() {
//Declare button pins as input with the internal pullup resistor on
for (int i = 0; i < NUM_BUTTONS; i++) {
pinMode(buttonList[i], INPUT_PULLUP);
}
//Declare our LED pins as outputs
pinMode(17, OUTPUT);
pinMode(18, OUTPUT);
pinMode(19, OUTPUT);
pinMode(20, OUTPUT);
}
void loop() {
//Read our analogue pots
//Remember that the analogue pin numbers are different than the digital ones!
//Read our button states
for (int i = 0; i < NUM_BUTTONS; i++) {
if (digitalRead(buttonList[i]) == HIGH) { //Check to see if pin is HIGH
Joystick.button(i + 1, 0); //If pin is HIGH, button isn't pressed, so send 0
} else {
Joystick.button(i + 1, 1); //If pin is LOW, button is pressed, so send 1
}
}
//Special case for LED status lights
//Check status of button and change LED accordingly
if (digitalRead(12) == LOW) //Check if button is pressed/switch flipped
analogWrite(17, INTENSITY); //Set corresponding LED pin to intensity level
else
analogWrite(17, 0); //Otherwise turn off
if (digitalRead(7) == LOW) //Same for other pins
analogWrite(18, INTENSITY);
else
analogWrite(18, 0);
if (digitalRead(9) == LOW)
analogWrite(19, INTENSITY);
else
analogWrite(19, 0);
if (digitalRead(11) == LOW)
analogWrite(20, INTENSITY);
else
analogWrite(20, 0);
Joystick.send_now(); //Send control states
Joystick.sendState()
delay(5); //Slow things down a bit
}