Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Teensy 2.0 keyboard Troubleshooting

  1. #1
    Junior Member
    Join Date
    May 2016

    Teensy 2.0 keyboard Troubleshooting

    Hello Everyone!

    I recently purchased a Teensy 2.0 for a school project. The goal is to design a mini keyboard with three buttons on it. When pressed buttons 1,2, and 3 will display inputs A,B, and C respectfully. If a button is held, only 1 input of A,B or C will be displayed. I programmed the Teensy 2.0 with Arduino language and downloaded the libraries to communicate with the Teensy 2.0. For some reason, only pin 10 works on the Teensy 2.0. If other pins are used, the display shows the input randomly and the buttons become unresponsive. The lines of code that creates the inputs A, B, and C works properly on pin 10. I comment out only one section of the line to verify the code works. I used different buttons to verify the buttons are correct as well. When attempting to use pins 1-9, the buttons do not work anymore. I move the Teensy 2.0 to other parts of the breadboard and it is still not working. I ruled out the code, buttons, or breadboard ports causing the problem and I believe is the Teensy 2.0 might be faulty. If anyone could give me another point of view that might be causing the problem would be great! If you need more information, do not be afraid to ask

    I am using an Teensy 2.0. sanwa buttons which uses two pins (power, ground) and a small breadboard.

    Below is the code I am currently using using Arduino:

    void setup() {
    pinMode(10, INPUT_PULLUP);

    int liftedA = 0;
    int liftedB = 0;
    int liftedC = 0;

    void loop() {
    //Print "A"

    if (digitalRead(10) == HIGH) {
    liftedA = 0;
    } else if (digitalRead(10) == LOW && liftedA == 0) {
    liftedA = 1;
    Keyboard.print("A"); // we print a space

    //Print "B"

    if (digitalRead(9) == HIGH) {
    liftedB = 0;
    } else if (digitalRead(9) == LOW && liftedB == 0) {
    liftedB = 1;
    Keyboard.print("B"); // "B" is printed

    //Print "C"

    if (digitalRead(8) == HIGH) {
    liftedC = 0;
    } else if (digitalRead(8) == LOW && liftedC == 0) {
    liftedC = 1;
    Keyboard.print("C"); // we print a space

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Colmar, France
    That can't work with other/more pins if you do not declare these as input pins and configure them with the internal pulp resistor at the beginning. For use with pins 8, 9, and 10, you have to put the following three lines into the setup() function :
    pinMode(8, INPUT_PULLUP);
    pinMode(9, INPUT_PULLUP);
    pinMode(10, INPUT_PULLUP); // is already there

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Yes, Theremingenieur is correct about needing pinMode.

    You should also use the Bounce library. It's much better than delay & digitalRead. See File > Examples > Teensy > USB_Keyboard > Buttons for an example.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts