teensy 2.0 help
-
- Posts: 34
- Joined: Tue Jun 28, 2016 12:44 pm
- Has thanked: 5 times
- Been thanked: 2 times
teensy 2.0 help
hi i have a teensy 2.0 in my gbz. i have built it with 4 buttons on the back l1 l2 r1 r2 the arduino code in the guide works for everything but the back 4, any way i could make this work any help would be much appreciated
- wermy
- Site Admin
- Posts: 1346
- Joined: Tue May 03, 2016 8:51 pm
- Has thanked: 620 times
- Been thanked: 1322 times
- Contact:
Re: teensy 2.0 help
You should just need to add a couple more buttons in the setup method, and change the number of buttons at the top. Try this out:kylewismith wrote:hi i have a teensy 2.0 in my gbz. i have built it with 4 buttons on the back l1 l2 r1 r2 the arduino code in the guide works for everything but the back 4, any way i could make this work any help would be much appreciated
Code: Select all
#include <Bounce.h>
#define NUM_KEYS 14
struct Key {
char keycode;
Bounce* bounce;
};
Key keys[NUM_KEYS];
Key key(char keycode, int pin) {
Key *ret = new Key;
ret->keycode = keycode;
ret->bounce = new Bounce(pin, 10);
pinMode(pin, INPUT_PULLUP);
return *ret;
}
void setupKeys() {
keys[0] = key('w', 0);
keys[1] = key('s', 1);
keys[2] = key('a', 2);
keys[3] = key('d', 3);
keys[4] = key('p', 4);
keys[5] = key('l', 5);
keys[6] = key('o', 6);
keys[7] = key('k', 7);
keys[8] = key('x', 8);
keys[9] = key('z', 9);
keys[10] = key('q',10);
keys[11] = key('e',11);
keys[12] = key('r',12);
keys[13] = key('t',13);
}
void setup() {
setupKeys();
Keyboard.begin();
// pinMode(0, INPUT_PULLUP);
}
void loop() {
for (int i = 0; i < NUM_KEYS; i++) {
keys[i].bounce->update();
if (keys[i].bounce->fallingEdge()) {
Keyboard.press(keys[i].keycode);
} else if (keys[i].bounce->risingEdge()) {
Keyboard.release(keys[i].keycode);
}
}
}
-
- Posts: 34
- Joined: Tue Jun 28, 2016 12:44 pm
- Has thanked: 5 times
- Been thanked: 2 times
Re: teensy 2.0 help
Brilliant that worked a treat thanks alot for you help. I also had the wires soldered at the wrong end ha
Re: teensy 2.0 help
I'm having some problems with the Teensy 2.0, also. It seems that the Teensy loader isn't connecting to the Teensy. The Program and Reboot buttons are gray. Also, IDE says the Teensy isn't responding to USB requests.
I'm using Arduino IDE 1.6.9 and TeensyLoader 1.36
I'm using Arduino IDE 1.6.9 and TeensyLoader 1.36
Who is online
Users browsing this forum: No registered users and 1 guest