IAmOrion wrote: ↑Thu Jun 16, 2016 7:46 am
I've started building my GBZ now
- Big thanks to [mention=dominator]Dominator[/mention] for sending me the GBZ PCB and some stickers and buttons.
Anyway, I opted to use the Leonardo Micro instead of a teensy, pretty much same size.
http://www.ebay.co.uk/itm/201310315804
I wanted to share my arduino code that I used. I've used this same code on a Retro Arcade Machine Coffee Table I built
Code: Select all
#include <Keyboard.h>
#define BUTTONS 15
int pin_arr[]={2,4,3,5,14,16,9,8,A0,A1,6,7,A2,A3,15};
int keycode_arr[]={218,217,216,215,128,130,32,129,122,176,53,49,112,177,179};
// UP,DOWN,LEFT,RIGHT,LEFT-CTRL (Button 1), LEFT-ALT (Button 2),SPACEBAR (Button 3), LEFT-SHIFT (Button 4), Z (Button 5), ENTER (Button 6) (Enter instead of X so can use with other RPi things like raspi-config), Coin/Credit, 1P Start, P (Pause), ESC, TAB
int key_state[BUTTONS];
void setup() {
Keyboard.begin();
for (int i=0;i<BUTTONS;i++)
{
pinMode(pin_arr[i], INPUT_PULLUP);
key_state[i] = digitalRead(pin_arr[i]);
}
}
void loop() {
for (int i=0;i<BUTTONS;i++)
{
key_state[i]=digitalRead(pin_arr[i]);
if (key_state[i]==LOW) {
Keyboard.press(keycode_arr[i]); if (keycode_arr[i] == 49) { delay(100); }
} else {
Keyboard.release(keycode_arr[i]);
}
}
}
Download link:
https://www.dropbox.com/s/hvwi92295z8qs ... o.zip?dl=1
the download also includes an additional header (not included in the compilation as it's for reference only) That lists all the Key Codes.
I hope this is of use to others
Hi, I am having some problems with getting this to work, but i'm a total noob here so i just try to follow the guides step by step as best i can. But i get the following error message
Arduino: 1.6.5 (Windows 8.1), Board: "Arduino Leonardo"
test.ino: In function 'void setup()':
test:9: error: 'Keyboard' only supported on the Arduino Leonardotest.ino: In function 'void loop()':
test:22: error: 'Keyboard' only supported on the Arduino Leonardotest:24: error: 'Keyboard' only supported on the Arduino Leonardo'Keyboard' only supported on the Arduino Leonardo
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
I'm using the following code
Code: Select all
//#include <Keyboard.h>
#define BUTTONS 15
int pin_arr[]={2,4,3,5,14,16,9,8,A0,A1,6,7,A2,A3,15};
int keycode_arr[]={218,217,216,215,128,130,32,129,122,176,53,49,112,177,179};
// UP,DOWN,LEFT,RIGHT,LEFT-CTRL (Button 1), LEFT-ALT (Button 2),SPACEBAR (Button 3), LEFT-SHIFT (Button 4), Z (Button 5), ENTER (Button 6) (Enter instead of X so can use with other RPi things like raspi-config), Coin/Credit, 1P Start, P (Pause), ESC, TAB
int key_state[BUTTONS];
void setup() {
Keyboard.begin();
for (int i=0;i<BUTTONS;i++)
{
pinMode(pin_arr[i], INPUT_PULLUP);
key_state[i] = digitalRead(pin_arr[i]);
}
}
void loop() {
for (int i=0;i<BUTTONS;i++)
{
key_state[i]=digitalRead(pin_arr[i]);
if (key_state[i]==LOW) {
Keyboard.press(keycode_arr[i]); if (keycode_arr[i] == 49) { delay(100); }
} else {
Keyboard.release(keycode_arr[i]);
}
}
}
If i do not comment out the first line i get this this error:
Arduino: 1.6.5 (Windows 8.1), Board: "Arduino Leonardo"
test.ino:1:22: fatal error: Keyboard.h: No such file or directory
compilation terminated.
Error compiling.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino version 1.6.5
Tool - Board - Arduino Leonardo
Port:Com1
Programmer: AVRISP mkll
Any help i can get is appreciated
any more info i should provide then please let me know.