Teensy LC soldering error- teensyduino fix?

Hardware-related questions that don't fit into any of the specialized hardware categories go here.
Post Reply
petran1420
Posts: 96
Joined: Sun May 08, 2016 8:59 pm
Has thanked: 1 time
Been thanked: 18 times

Teensy LC soldering error- teensyduino fix?

Post by petran1420 » Sun May 08, 2016 9:13 pm

Hi there,

I just finished soldering all the pcb wires into my teensy LC, and realized I accidentally skipped GPIO 0, and started from 1. Thus, all of the pin positions are shifted over one space, so instead 0-11 it goes from 1-12. Rather than re solder back everything one space, I'm thinking I'd prefer to update the provided code to reflect the new wired positions in the Teensy. I'm new to the teensyduino library and thus their commands in the arduino IDE so I could use some help.

I figured I'd just have to alter the setupkeys function, but so far the gamepad doesn't work. Here's the code so far:

Code: Select all

#include <Bounce.h>

#define NUM_KEYS 12

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[1] = key('w', 1);
  keys[2] = key('s', 2);
  keys[3] = key('a', 3);
  keys[4] = key('d', 4);
  keys[5] = key('p', 5);
  keys[6] = key('l', 6);
  keys[7] = key('o', 7);
  keys[8] = key('k', 8);
  keys[9] = key('x', 9);
  keys[10] = key('z', 10);
  keys[11] = key('q',11);
  keys[12] = key('e',12);
}

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);
    }
  }
}
I'm sure i'm missing something, though. Any ideas? Or should I just re solder all the wires back into their intended spaces?

petran1420
Posts: 96
Joined: Sun May 08, 2016 8:59 pm
Has thanked: 1 time
Been thanked: 18 times

Re: Teensy LC soldering error- teensyduino fix?

Post by petran1420 » Sun May 08, 2016 9:29 pm

Update: I adjusted the setupKeys function to look like this:

Code: Select all

void setupKeys() {
  keys[0] = key('w', 1);
  keys[1] = key('s', 2);
  keys[2] = key('a', 3);
  keys[3] = key('d', 4);
  keys[4] = key('p', 5);
  keys[5] = key('l', 6);
  keys[6] = key('o', 7);
  keys[7] = key('k', 8);
  keys[8] = key('x', 9);
  keys[9] = key('z', 10);
  keys[10] = key('q',11);
  keys[11] = key('e',12);
}
Now, some of the buttons work, but only X, Y, A, and the Right D-pad. Not sure if this is due to incorrect adjustment within the program, or poor soldering on the PCB. I know I had a very hard time 'bridging' all the ground traces so it may have something to do with that as well, but I'd like to eliminate software as a possible option first.

User avatar
Camble
Posts: 881
Joined: Thu May 05, 2016 2:31 am
Location: Scotland
Has thanked: 269 times
Been thanked: 487 times

Re: Teensy LC soldering error- teensyduino fix?

Post by Camble » Mon May 09, 2016 6:29 am

Yes, leave the first line as keys[0] as this is the first index of the "keys" array, not the pin marked 0.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest