Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Joystick.h>
- #include "Keyboard.h"
- char lookfront = 3;
- char switchA2 = 0;
- char switchA3 = 0;
- char switch1 = 0;
- char switch19 = 0;
- void setup() {
- pinMode(2, INPUT_PULLUP);
- pinMode(3, INPUT_PULLUP);
- pinMode(4, INPUT_PULLUP);
- pinMode(5, INPUT_PULLUP);
- pinMode(6, INPUT_PULLUP);
- pinMode(7, INPUT_PULLUP);
- pinMode(8, INPUT_PULLUP);
- pinMode(9, INPUT_PULLUP);
- pinMode(10, INPUT_PULLUP);
- pinMode(14, INPUT_PULLUP);
- pinMode(15, INPUT_PULLUP);
- pinMode(16, INPUT_PULLUP);
- pinMode(A0, INPUT_PULLUP);
- pinMode(A1, INPUT_PULLUP);
- pinMode(A2, INPUT_PULLUP);
- pinMode(A3, INPUT_PULLUP);
- Joystick.begin();
- Keyboard.begin();
- }
- void loop() {
- if (digitalRead(2) == LOW && (switch1 == 0))
- {
- Joystick.setButton(0, 1);
- delay(90);
- Joystick.setButton(0, 0);
- switch1 = 1;
- }
- if (digitalRead(2) == HIGH && (switch1 == 1))
- {
- Joystick.setButton(0, 1);
- delay(90);
- Joystick.setButton(0, 0);
- switch1 = 0;
- }
- if (digitalRead(3) == LOW)
- {
- Keyboard.press(176); //enter
- delay(100);
- }
- else
- {
- Keyboard.release(176);
- }
- if (digitalRead(4) == LOW)
- {
- Joystick.setButton(4, 1);
- }
- else
- {
- Joystick.setButton(4, 0);
- }
- if (digitalRead(5) == LOW)
- {
- Joystick.setButton(5, 1);
- }
- else
- {
- Joystick.setButton(5, 0);
- }
- if (digitalRead(6) == LOW)
- {
- Keyboard.press(177); //esc
- delay(100);
- }
- else
- {
- Keyboard.release(177);
- }
- if (digitalRead(7) == LOW)
- {
- Joystick.setButton(7, 1);
- }
- else
- {
- Joystick.setButton(7, 0);
- }
- if (digitalRead(8) == LOW)
- {
- Joystick.setButton(8, 1);
- }
- else
- {
- Joystick.setButton(8, 0);
- }
- if (digitalRead(9) == LOW)
- {
- Keyboard.press(179); //tab
- delay(100);
- }
- else
- {
- Keyboard.release(179);
- }
- if (digitalRead(10) == LOW)
- {
- Joystick.setButton(10, 1);
- }
- else
- {
- Joystick.setButton(10, 0);
- }
- if (digitalRead(14) == LOW)
- {
- Joystick.setButton(14, 1);
- }
- else
- {
- Joystick.setButton(14, 0);
- }
- if (digitalRead(15) == LOW)
- {
- Joystick.setButton(15, 1);
- }
- else
- {
- Joystick.setButton(15, 0);
- }
- if (digitalRead(16) == LOW)
- {
- Joystick.setButton(16, 1);
- }
- else
- {
- Joystick.setButton(16, 0);
- }
- if (digitalRead(A0) == LOW)
- {
- Joystick.setButton(17, 1);
- }
- else
- {
- Joystick.setButton(17, 0);
- }
- if (digitalRead(A1) == LOW && (switch19 == 0))
- {
- Joystick.setButton(18, 1);
- delay(90);
- Joystick.setButton(18, 0);
- switch19 = 1;
- }
- if (digitalRead(A1) == HIGH && (switch19 == 1))
- {
- Joystick.setButton(18, 1);
- delay(90);
- Joystick.setButton(18, 0);
- switch19 = 0;
- }
- if (digitalRead(A2) == LOW && (switchA2 == 0)) //RIGHT LOOK
- {
- Joystick.setButton(19, 1);
- delay(90);
- Joystick.setButton(19, 0);
- switchA2 = 1;
- }
- if (digitalRead(A2) == HIGH && (switchA2 == 1)) //RIGHT LOOK
- {
- Joystick.setButton(20, 1);
- delay(90);
- Joystick.setButton(20, 0);
- switchA2 = 0;
- }
- if (digitalRead(A3) == LOW && (switchA3 == 0)) //RIGHT LOOK
- {
- Joystick.setButton(21, 1);
- delay(90);
- Joystick.setButton(21, 0);
- switchA3 = 1;
- }
- if (digitalRead(A3) == HIGH && (switchA3 == 1)) //RIGHT LOOK
- {
- Joystick.setButton(20, 1);
- delay(90);
- Joystick.setButton(20, 0);
- switchA3 = 0;
- }
- delay(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement