2.Controlling LEDs with a Keypad and Arduino
Controlling LEDs with a Keypad and Arduino Components Needed: Arduino board 4x4 or 4x3 Keypad LEDs (e.g., 3 LEDs) Resistors (e.g., 220Ω for each LED) Jumper wires Breadboard (optional) Connections: Keypad : Connect the keypad pins to digital pins on your Arduino (e.g., rows to pins 9, 8, 7, 6 and columns to pins 5, 4, 3, 2). LEDs : Connect the LEDs to digital pins (e.g., LED1 to pin 13, LED2 to pin 12, LED3 to pin 11). Don’t forget to add a current-limiting resistor in series with each LED. Example Code: C++ Code # include <Keypad.h> const byte ROWS = 4 ; // Number of rows const byte COLS = 4 ; // Number of columns char keys[ROWS][COLS] = { { '1' , '2' , '3' , 'A' }, { '4' , '5' , '6' , 'B' }, { '7' , '8' , '9' , 'C' }, { '*' , '0' , '#' , 'D' } }; byte rowPins[ROWS] = { 9 , 8 , 7 , 6 }; // Connect to row pins of keypad byte colPins...
Comments
Post a Comment