hello,and thank you for your help ,i'm working on a small project
i'm trying to controle an LCD 16×2 screen with a 4×4 keypad using PCF8574A,all i need it to do is " a security password program .after entering the password i want to be able to insert a temperature degree like a kitochen oven when u enter the temperature to cook something please help me
We know what you want. Now we need to know what you have done. Can you write to the LCD? Can you read a character or characters from the keypad? Can you display characters from the keypad on the LCD?
What code have you tried?
i found a password program online and i tried to add the temperture code but it wont work
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
#define Password_Length 4
int signalPin = 12;
char Data[Password_Length];
char Master[Password_Length] = "123";
byte data_count = 0, master_count = 0;
bool Pass_is_good = false;
char customKey;
const byte ROWS = 4;
const byte COLS = 4;
char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
LiquidCrystal_I2C lcd(0X38, 16, 2);
void setup(){
lcd.init();
lcd.backlight();
pinMode(signalPin, OUTPUT);
}
void loop(){
if (Pass_is_good == true)
{
lcd.setCursor(0,0);
lcd.print("d");
lcd.setCursor(1,0);
lcd.print("o");
lcd.setCursor(2,0);
lcd.print("n");
lcd.setCursor(3,0);
lcd.print("n");lcd.setCursor(4,0);
lcd.print("e");lcd.setCursor(5,0);
lcd.print("r");lcd.setCursor(6,0);
lcd.print(" ");lcd.setCursor(7,0);
lcd.print("t");lcd.setCursor(8,0);
lcd.print("e");lcd.setCursor(9,0);
lcd.print("m");lcd.setCursor(10,0);
lcd.print("p");lcd.setCursor(11,0);
customKey = customKeypad.getKey();
if (customKey){
Data[data_count] = customKey;
lcd.setCursor(data_count,1);
lcd.print(Data[data_count]);
data_count++;
}
if(data_count == Password_Length-1){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("t");
lcd.setCursor(1,0);
lcd.print("e");
lcd.setCursor(2,0);
lcd.print("m");
lcd.setCursor(3,0);
lcd.print("p");lcd.setCursor(4,0);
lcd.print(":");
lcd.setCursor(0,1);
lcd.print(Data[0]);
lcd.setCursor(1,1);
lcd.print(Data[1]);
lcd.setCursor(2,1);
lcd.print(Data[2]);
delay (2000);
lcd.clear();
clearData();
}
}
else
{
lcd.setCursor(0,0);
lcd.print("E");
lcd.setCursor(1,0);
lcd.print("n");
lcd.setCursor(2,0);
lcd.print("t");
lcd.setCursor(3,0);
lcd.print("e");lcd.setCursor(4,0);
lcd.print("r");lcd.setCursor(5,0);
lcd.print(" ");lcd.setCursor(6,0);
lcd.print("P");lcd.setCursor(7,0);
lcd.print("a");lcd.setCursor(8,0);
lcd.print("s");lcd.setCursor(9,0);
lcd.print("s");lcd.setCursor(10,0);
lcd.print("w");lcd.setCursor(11,0);
lcd.print("o");lcd.setCursor(12,0);
lcd.print("r:");lcd.setCursor(13,0);
lcd.print("d:");
}
customKey = customKeypad.getKey();
if (customKey){
Data[data_count] = customKey;
lcd.setCursor(data_count,1);
lcd.print(Data[data_count]);
data_count++;
}
if(data_count == Password_Length-1){
lcd.clear();
if(!strcmp(Data, Master)){
lcd.print("Correct");
digitalWrite(signalPin, HIGH); lcd.setCursor(0,0);
// lcd.print("donner la température : ");
delay(2000);
digitalWrite(signalPin, LOW);
Pass_is_good = true;
}
else{
lcd.print("Incorrect");
delay(1000);
}
lcd.clear();
clearData();
}
}
void clearData(){
while(data_count !=0){
Data[data_count--] = 0;
// if(!strcmp(Data, Master)&&(data_count == Password_Length-1)){ lcd.print("donner la temperature");}
}
return;
// if(!strcmp(Data, Master)&&(data_count == Password_Length-1)){ lcd.print("donner la temperature");}
}
"It won't work" is an inadequate description of the problem(s).
Please read this post on how to as a programming question. Following those guidelines will save us a lot of time.