Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Petry Arcade Stick --- Arduino section
- Reads inputs from joystick microswitches and sends the data out over serial (115200 baud) as a int
- */
- // constants won't change. They're used here to
- // set pin numbers:
- const int down = 6;
- const int up = 7;
- const int left = 4;
- const int right = 5;
- const int trigger = 3;
- // variables will change:
- int output = 0;
- void setup() {
- Serial.begin(115200);
- pinMode(down, INPUT_PULLUP);
- pinMode(right, INPUT_PULLUP);
- pinMode(left, INPUT_PULLUP);
- pinMode(up, INPUT_PULLUP);
- pinMode(trigger, INPUT_PULLUP);
- }
- void loop() {
- if (digitalRead(up) == LOW) {
- output = 1 + output;
- }
- if (digitalRead(right) == LOW) {
- output = 7 + output;
- }
- if (digitalRead(down) == LOW) {
- output = 11 + output;
- }
- if (digitalRead(left) == LOW) {
- output = 15 + output;
- }
- if (digitalRead(trigger) == LOW) {
- output = 19 + output;
- }
- Serial.println(output);
- output = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement