Skip to content

Instantly share code, notes, and snippets.

@JohnathonNow
Forked from anonymous/Atari2600USB.ino
Created February 2, 2017 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohnathonNow/f1c68d917c22ae4c469a391d3c4d951b to your computer and use it in GitHub Desktop.
Save JohnathonNow/f1c68d917c22ae4c469a391d3c4d951b to your computer and use it in GitHub Desktop.
A simple program for the Digispark Pro for reading in 10 digital inputs and mapping them to joystick buttons.
#include "DigiJoystick.h"
char BUTS[] = { 6, 5, 2, 1, 0, 7, 8, 9, 10, 11 };
void setup() {
for (int i = 0; i < 10; i++) {
pinMode(BUTS[i], INPUT);
}
}
void loop() {
DigiJoystick.delay(50);
int p = 0;
for (int i = 0; i < 10; i++) {
p |= digitalRead(BUTS[i])<<i;
}
DigiJoystick.setButtons((char)(p&0xFF), (p>>8)&0xFF);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment