Paso 1: El código
El código es largo, pero sus piezas esenciales son simples. Aquí está:
#include < Esplora.h >
Boolean buttonStates [8];
byte const botones [] = {}
JOYSTICK_DOWN,
JOYSTICK_LEFT,
JOYSTICK_UP,
JOYSTICK_RIGHT,
SWITCH_RIGHT,
SWITCH_LEFT,
SWITCH_UP,
SWITCH_DOWN,
};
const char teclado [] = {}
DE ',
'A',
'W',
HABÍA ',
'Q ',
'X',
' T ',
'Z'
};
Puede cambiar las teclas que usted desee.
void setup() {}
Keyboard.Begin();
}
void loop() {}
para (thisButton byte = 0; thisButton < 8; thisButton ++) {}
Boolean lastState = buttonStates [thisButton];
newState booleano = Esplora.readButton(buttons[thisButton]);
Si (lastState! = newState) {}
Si (newState == presionado) {}
Keyboard.Press(Keystrokes[thisButton]);
}
else if (newState == liberado) {}
Keyboard.Release(Keystrokes[thisButton]);
}
}
buttonStates [thisButton] = newState;
}
Delay(50);
xAxis int = Esplora.readAccelerometer(X_AXIS);
Si (xAxis < 0) {Keyboard.press('E'); delay(50);
};
Si (xAxis > 50) {}
Keyboard.Press('Q');
Delay(50);
};
Delay(50);
}