simple demostration
Dependencies: Hotboards_keypad mbed
Revision 1:1b1de1bdac89, committed 2016-03-08
- Comitter:
- RomanValenciaP
- Date:
- Tue Mar 08 21:34:10 2016 +0000
- Parent:
- 0:62b7e7dd5ba4
- Commit message:
- comments
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Mar 05 00:05:26 2016 +0000
+++ b/main.cpp Tue Mar 08 21:34:10 2016 +0000
@@ -2,6 +2,8 @@
#include "mbed.h"
#include "Hotboards_keypad.h"
+// Se define el arreglo keys con su respectivo número de renglones
+// y columnas, y con el valor de cada una de las teclas
char keys[ 4 ][ 4 ] =
{
{ '1' , '2' , '3' , 'A' },
@@ -10,21 +12,28 @@
{ '*' , '0' , '#' , 'D' }
};
+// Se definen los pines que conectan a las filas
DigitalInOut rowPins[ 4 ] = { PA_6 , PA_7 , PB_6 , PC_7 };
+// Se definen los pines que conectan a las columnas
DigitalInOut colPins[ 4 ] = { PA_8 , PB_10 , PB_4 , PB_5 };
+// Se crea un nuevo teclado con los valores anteriores
Keypad kpd( makeKeymap( keys ) , rowPins , colPins , 4 , 4 );
+// Se configura el puerto serial
Serial pc( USBTX , USBRX );
int main()
{
while(1)
{
+ // Se pregunta por cualquier tecla presionada
char key = kpd.getKey( );
+ // Si se presiona una tecla "key" tendrá un valor diferente de cero
if( key )
{
+ // Se manda al puerto serial la tecla presionada
pc.printf( "%c" , key );
pc.printf( "\n\r" );
}
Roman Valencia