Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Keyboard.h" //include the library used for keyboard commands
- void setup() {
- delay(5000);
- pinMode(3, INPUT_PULLUP); //define all pins used as inputs
- pinMode(4, INPUT_PULLUP);
- pinMode(5, INPUT_PULLUP);
- pinMode(6, INPUT_PULLUP);
- pinMode(7, INPUT_PULLUP);
- pinMode(8, INPUT_PULLUP);
- pinMode(9, INPUT_PULLUP);
- Keyboard.begin();
- }
- void loop() {
- int Fire = digitalRead(3); //define Fire as read pin 3
- int Up = digitalRead(4); //define Up as read pin 4
- int Down = digitalRead(5); //define Down as read pin 5
- int Right = digitalRead(6); //define Right as read pin 6
- int Left = digitalRead(7); //define Left as read pin 7
- int Reset = digitalRead(8); //define Reset as read pin 8
- int Pause = digitalRead(9); //define Pause as read pin 9
- if (Fire == LOW)
- {
- Keyboard.press('z'); // If fire key (which is pin 3) goes low to press key 32 (spacebar)
- }
- if (Fire == HIGH)
- {
- Keyboard.release('z'); // If fire key (which is pin 3) goes high to release key 32 (spacebar)
- }
- if (Up == LOW)
- {
- Keyboard.press(217);
- }
- if (Up == HIGH)
- {
- Keyboard.release(217);
- }
- if (Down == LOW)
- {
- Keyboard.press(218);
- }
- if (Down == HIGH)
- {
- Keyboard.release(218);
- }
- if (Left == LOW)
- {
- Keyboard.press(215);
- }
- if (Left == HIGH)
- {
- Keyboard.release(215);
- }
- if (Right == LOW)
- {
- Keyboard.press(216);
- }
- if (Right == HIGH)
- {
- Keyboard.release(216);
- }
- if (Reset == LOW)
- {
- Keyboard.press(176); // If reset key (which is pin 8) goes low to press key 224 (return)
- }
- if (Reset == HIGH)
- {
- Keyboard.release(176);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement