Teensy 2.0 Row and columns

Status
Not open for further replies.

usajet

New member
If I want to use this teensy 2.0 board and a button only board how can I determined on which are rows and columns? This is for matrix purposes.



Thank you Nathan
 
If I understand well, you want to read a button matrix with your Teensy. In that case, it is up to you as the software developer to define which pins output signals to the columns and which pins read signals from the rows (or the other way round), and to write the corresponding code.
You might google around to find a button matrix library if you prefer using prefabricated code. There is one for the Teensy, but I‘m not sure if it is compatible to the older Teensy 2.x series.
 
Yes you are understanding me well. I don't know how to assign rows or columns. DO you know anything off hand what would be a good place to start?
 
First, one would have to define the number of buttons which would have to be read. Often, the Teensy 2.0++ or the Teensy 3.5/6 have enough pins to read many buttons directly, without matrix, depending on the number of pins which you‘ll perhaps need afterwards for other functionalities. If you really must go for a matrix, you trade less used pins for more complex code. So, for 20 buttons, you would not longer need 20 pins, but only 9 (4 cols x 5 rows).
A matrix consists of rows and columns and the buttons are wired in a way that each button, when pressed, connects exactly one column wire with one row wire. Now comes the code side: In a loop, the column wires will be driven high for a short interval (i.e. 20ms) and then again low, one after the other, in a cyclic way. Each time, one column wire is driven high, all row pins will be read to see if one of the buttons in this columns is pressed. From the number of the actual high column and the row pin which is driven high, the code will know which button is pressed and can invoke any action which is intended to happen whet his specific button is pressed.
Basically, it‘s relatively simple - no black magic! In reality, after a button press is detected, your code would first check if that button was already pressed during the last column cycle, to prevent repeated triggering. That‘s all.
 
In Arduino (with Teensyduino installed), first make sure Teensy is selected in Tools > Boards, because the other Arduino menus update depending on the board selected.

The click File > Examples > Keypad > HelloKeypad. Even if your keypad has more wires, connect 4 of its rows to pins 2-5 and 3 of its columns to pins 6-8 and run the example. Open the serial monitor, press all the buttons and what when prints in the serial monitor. When you get that working, hopefully you'll see a path forward to edit the example for more rows or columns.
 
Status
Not open for further replies.
Back
Top