#include "Keypad.h"
char Incoming_value = 0;
String password = "123456";
String input = "";
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {2, 3, 4, 5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6,7,8,9}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop()
{
if (Serial.available() > 0)
{
Incoming_value = Serial.read();
Serial.print(Incoming_value);
Serial.print("enter value");
if (Incoming_value == '1') {
digitalWrite(13, HIGH);
Serial.print("ON");
}
else if (Incoming_value == '0') {
Serial.print("OFF");
digitalWrite(13, LOW);
}
}
// Read the pushed button
char key = keypad.getKey();
input = input + key;
// just print the pressed key
if (key) {
Serial.println(key);
}
if(key == '*' ){
Serial.println(input);
if( input == password){
digitalWrite(13, HIGH);
}
}
if(key == '#'){
digitalWrite(13, LOW);
input = "";
}
/*
// this checkes if 4 is pressed, then do something. Here we print the text but you can control something.
if (key == '4') {
Serial.println("Key 4 is pressed");
digitalWrite(13, HIGH);
Serial.print("ON");
}
if (key == '5') {
Serial.println("Key 5 is pressed");
digitalWrite(13, LOW);
Serial.print("ON");
}
*/
}
when print input variable i get strange text like
⸮⸮⸮⸮⸮⸮⸮;⸮⸮ߵ⸮⸮⸮⸮u⸮⸮⸮⸮⸮⸮?/}⸮⸮⸮⸮⸮⸮~⸮⸮⸮⸮⸮-d
what i can do ?
void loop()shellapp. You'll see the same strange thing happeningvoid loop()in you sketch and see if it works.