100% found this document useful (1 vote)
94 views4 pages

Arduino Keypad

The document defines code for an Arduino project that uses a 4x3 keypad connected to an Arduino. It initializes the keypad by defining the number of rows and columns, mapping the keys, and connecting the rows and columns to Arduino pins. It then defines a loop to read the keypad, print any pressed keys to the serial monitor, and turn on an LED.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
94 views4 pages

Arduino Keypad

The document defines code for an Arduino project that uses a 4x3 keypad connected to an Arduino. It initializes the keypad by defining the number of rows and columns, mapping the keys, and connecting the rows and columns to Arduino pins. It then defines a loop to read the keypad, print any pressed keys to the serial monitor, and turn on an LED.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

#include <Keypad.

h>

const byte ROWS = 4; // Four rows

const byte COLS = 3; // Three columns

// Define the Keymap

char keys[ROWS][COLS] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'},


{'#','0','*'} };

// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these


Arduino pins.

byte rowPins[ROWS] = { 9, 8, 7, 6 };

// Connect keypad COL0, COL1 and COL2 to these Arduino pins.

byte colPins[COLS] = { 12, 11, 10 };

// Create the Keypad Keypad kpd = Keypad( makeKeymap(keys),


rowPins, colPins, ROWS, COLS );

#define ledpin 13

void setup()

pinMode(ledpin,OUTPUT);

digitalWrite(ledpin, HIGH);

Serial.begin(9600);

void loop()
{

char key = kpd.getKey();

if(key) // Check for a valid key.

switch (key)

case '1':

Serial.println(key);

break;

case '2':

Serial.println(key);

break;

case '3':

Serial.println(key);

break;

case '4':

Serial.println(key);

break;

case '5':

Serial.println(key);
break;

case '6':

Serial.println(key);

break;

case '7':

Serial.println(key);

break;

case '8':

Serial.println(key);

break;

case '9':

Serial.println(key);

break;

case '0':

Serial.println(key);

break;

case '*':

Serial.println(key);

break;

case '#':
Serial.println(key);

break;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy