Hello
I am creating an Arduino sketch that uses a keypad to define the approximated output analog voltage that will light the LED connected to the Arduino on pin 11. This means that by entering a three-digit number into the keypad, you can control the intensity of the LED lighting connected to pin 11 via an Arduino output PWM.
the issue is I am still new and don't know how to make a keypad have more than single input, I have done what I can from what I read but I am stuck
//c++
//
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'},
};
byte rowPins[ROWS] = {7,6,5,4}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {A3,A2,A1,A0}; //connect to the column pinouts of the keypad
Keypad myKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
int value = 0;
void setup(){
Serial.begin(9600);
Serial.println("Enter 3 digits");
}
void loop(){
char key = myKeypad.getKey();
if (key != NO_KEY && key != '#'){
Serial.print(key); //prints input digit
for (int i = 3; i != 0; i--) { //shifts digits to left
value = value * 10 + key - '0';
}
}
if (key == '#'){ //prints value
Serial.println ();
Serial.print (value);
Serial.println ();
}
value = 0;
}