Teensy tutorial : Keypad 4x3
Teensy tutorial : Keypad 4x3
in this tutorial I will connect the Keypad with teensy board , if you familiar with arduino and keypad before , you must not have any trouble here.
the hard thing to do is to know where is the row and column pins
from arduino playground page i quote the procedure you must to do to know where are the row and column pins
First you need to get a piece of paper and draw the right hand diagram as you see it below. I've already written my pin numbers (1,2,3 across the bottom and 7,6,5,4 down the right side) which you can just leave off of your drawing. Next, you are going to use your Ohm meter to find out which pins are connected to which keys. The first thing to do is count how many pins are on your keypad (as seen in the photo below.) The photo is showing 14 pins though not all of the pins are used. Don't worry, once you've completed this procedure you will know which pins are unused and can be ignored.
the hard thing to do is to know where is the row and column pins
from arduino playground page i quote the procedure you must to do to know where are the row and column pins
First you need to get a piece of paper and draw the right hand diagram as you see it below. I've already written my pin numbers (1,2,3 across the bottom and 7,6,5,4 down the right side) which you can just leave off of your drawing. Next, you are going to use your Ohm meter to find out which pins are connected to which keys. The first thing to do is count how many pins are on your keypad (as seen in the photo below.) The photo is showing 14 pins though not all of the pins are used. Don't worry, once you've completed this procedure you will know which pins are unused and can be ignored.
as you can see on the pictures below , I tested my keypad using the multimeter.
download the code from HERE
//Name :Mohannad Rawashdeh . //Date "25/2/2017 3:00pm //**************************************************************** int t=10; byte C1=2; byte C2=3; byte C3=4; //............ byte R1=5; byte R2=6; byte R3=7; byte R4=8; //............ boolean Button_state=1; byte led=11; //........... byte row[]={5,6,7,8}; byte col[] ={2,3,4}; //........... char Button[4][3] = { { '1','2','3'}, { '4','5','6'}, { '7','8','9'}, { '*','0','#'} }; void setup(){ Serial.begin(9600); pinMode(R1,OUTPUT); pinMode(R2,OUTPUT); pinMode(R3,OUTPUT); pinMode(R4,OUTPUT); //........ pinMode(C1,INPUT_PULLUP); pinMode(C2,INPUT_PULLUP); pinMode(C3,INPUT_PULLUP); pinMode(led,OUTPUT); //............. digitalWrite(R1,HIGH); digitalWrite(R2,HIGH); digitalWrite(R3,HIGH); digitalWrite(R4,HIGH); } void loop(){ int x=0; for (int i=0;i<4;i++){ digitalWrite(row[i],LOW); delay(t); for (int j=0;j<3;j++){ digitalWrite(row[i],LOW); Button_state=digitalRead(col[j]); digitalWrite(row[i],HIGH); if (Button_state == 0){ digitalWrite(led,HIGH); Serial.print("Button Pushed "); x=i+j; Serial.println(Button[i][j]); delay(200); digitalWrite(led,LOW); } } } }
open the serial monitor and press the button to see the result.
also the LED will blink every time you press a button
Post a Comment