Page 1 of 1

teensy 2.0 help

Posted: Tue Jun 28, 2016 2:09 pm
by kylewismith
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

Re: teensy 2.0 help

Posted: Tue Jun 28, 2016 6:09 pm
by wermy
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
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:

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);
    }
  }
}

Re: teensy 2.0 help

Posted: Wed Jun 29, 2016 3:00 am
by kylewismith
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

Posted: Sat Apr 15, 2017 11:40 pm
by 9volt
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