//silvio
int pinos [] = {
0,1,2,3,4,5,6,7,8,9,10,11,12,13};
int lastButtonState[14] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0};
#include "Joystick.h"
#include <Encoder.h>
Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
JOYSTICK_TYPE_MULTI_AXIS, 14, 0,
false, false, false, true,true, false,
false, false, true, true, true);
void setup() {
Joystick.setAcceleratorRange(0, 1023);
Joystick.setBrakeRange(0, 1023);
Joystick.setRxAxisRange (0, 1023);
Joystick.setRyAxisRange (0, 1023);
Joystick.setSteeringRange(0, 1023);
for(int i=0; i<14; i++){
pinMode(pinos[i],INPUT_PULLUP);
}
Joystick.begin();
}
void loop() {
Joystick.setRyAxis (analogRead(A4));
Joystick.setAccelerator (analogRead(A2));
Joystick.setRxAxis (analogRead(A1));
Joystick.setSteering (analogRead(A0));
Joystick.setBrake (analogRead(A3));
for (int index = 0; index < 14; index++)
{
int currentButtonState = map(digitalRead(index + 0),HIGH,LOW,LOW,HIGH);
if (currentButtonState != lastButtonState[index])
{
Joystick.setButton(index, currentButtonState);
lastButtonState[index] = currentButtonState;
}
}
}