سلام
من قراره با کیپد،LCD و ماژول رله،یه همچین قفلی درست کنم
مشکل اینه که در زمان آپلود،خطا میده و آپلود نمیشه
حالا از شما درخواست دارم تا نگاهی به این بندازید و مشکل رو رفع کنید
کد:
خطا:
من قراره با کیپد،LCD و ماژول رله،یه همچین قفلی درست کنم
مشکل اینه که در زمان آپلود،خطا میده و آپلود نمیشه
حالا از شما درخواست دارم تا نگاهی به این بندازید و مشکل رو رفع کنید
کد:
#include <Password.h>#include <LiquidCrystal_I2C.h>
#include <Keypad.h>
//Most common adresses PCF8574 = 0x20, PCF8574A = 0x38,PCF8574AT = 0x3F
//PCF8574T = 0x27
#define I2C_ADDR 0x27
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
int buzzer = 3;
int relay = 9;
const int buttonPin = 5;
int buttonState = 0;
Password password = Password( "1654" );
const byte ROWS = 4; // Four rows
const byte COLS = 4; // Four columns
// Define the Keymap
char keys[ROWS][COLS] = {
{'1','2','3','A',},
{'4','5','6','B',},
{'7','8','9','C',},
{'*','0','#','D',}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = {
12, 13, A5, A4}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {
A3, A2, A1, A0};
// Create the Keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(){
pinMode(buttonPin, INPUT);
pinMode(relay, OUTPUT);
pinMode(buzzer, OUTPUT);
lcd.begin (16,2);
digitalWrite(relay, HIGH);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.print(" BlueCore Tech ");
lcd.setCursor(0,1);
lcd.print(" Acces Control ");
delay(5000);
lcd.clear();
lcd.print("Acces Code: ");
Serial.begin(9600);
keypad.addEventListener(keypadEvent);
keypad.setDebounceTime(100);
}
void loop(){
keypad.getKey();
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
lcd.clear();
}
}
void keypadEvent(KeypadEvent eKey){
switch (keypad.getState()){
case PRESSED:
digitalWrite(buzzer, HIGH);
delay(100);
digitalWrite(buzzer, LOW);
switch (eKey){
case 'A': guessPassword(); break;
lcd.print("*");
default:
password.append(eKey);
}
}
}
void guessPassword(){
LiquidCrystal_I2C
lcd(I2C_ADDR, En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
if (password.evaluate()){
digitalWrite(relay, LOW);
lcd.setCursor(0,0);
lcd.print("##CORRECT CODE##");
lcd.setCursor(4,1);
lcd.print("WELCOME!");
delay(10000);
digitalWrite(relay, HIGH);
password.reset();
lcd.clear();
lcd.print("Acces Code: ");
}
else{
digitalWrite(relay, HIGH);
lcd.setCursor(0,0);
lcd.print("###WRONG CODE###");
password.reset();
lcd.setCursor(2,1);
lcd.print("ACCES DENIED");
delay(3000);
lcd.clear();
lcd.print("Acces Code: ");
}
}
خطا:
Arduino: 1.8.15 (Windows 8.1), Board: "Arduino Uno"
D:\Electronic\Arduino\Project\LCD_kepad_reley\FMDF75LIOKBSZ60\FMDF75LIOKBSZ60.ino: In function 'void setup()':
FMDF75LIOKBSZ60:52:5: error: 'lcd' was not declared in this scope
lcd.begin (16,2);
^~~
FMDF75LIOKBSZ60:54:39: error: 'POSITIVE' was not declared in this scope
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
^~~~~~~~
D:\Electronic\Arduino\Project\LCD_kepad_reley\FMDF75LIOKBSZ60\FMDF75LIOKBSZ60.ino: In function 'void loop()':
FMDF75LIOKBSZ60:73:5: error: 'lcd' was not declared in this scope
lcd.clear();
^~~
D:\Electronic\Arduino\Project\LCD_kepad_reley\FMDF75LIOKBSZ60\FMDF75LIOKBSZ60.ino: In function 'void keypadEvent(KeypadEvent)':
FMDF75LIOKBSZ60:86:5: error: 'lcd' was not declared in this scope
lcd.print("*");
^~~
D:\Electronic\Arduino\Project\LCD_kepad_reley\FMDF75LIOKBSZ60\FMDF75LIOKBSZ60.ino: In function 'void guessPassword()':
FMDF75LIOKBSZ60:95:65: error: no matching function for call to 'LiquidCrystal_I2C::LiquidCrystal_I2C(int, int, int, int, int, int, int, int)'
lcd(I2C_ADDR, En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
^
In file included from D:\Electronic\Arduino\Project\LCD_kepad_reley\FMDF75LIOKBSZ60\FMDF75LIOKBSZ60.ino:9:0:
F:\Arduino\libraries\LiquidCrystal_I2C-master/LiquidCrystal_I2C.h:57:3: note: candidate: LiquidCrystal_I2C::LiquidCrystal_I2C(uint8_t, uint8_t, uint8_t)
LiquidCrystal_I2C(uint8_t lcd_Addr,uint8_t lcd_cols,uint8_t lcd_rows);
^~~~~~~~~~~~~~~~~
F:\Arduino\libraries\LiquidCrystal_I2C-master/LiquidCrystal_I2C.h:57:3: note: candidate expects 3 arguments, 8 provided
F:\Arduino\libraries\LiquidCrystal_I2C-master/LiquidCrystal_I2C.h:55:7: note: candidate: constexpr LiquidCrystal_I2C::LiquidCrystal_I2C(const LiquidCrystal_I2C&)
class LiquidCrystal_I2C : public Print {
^~~~~~~~~~~~~~~~~
F:\Arduino\libraries\LiquidCrystal_I2C-master/LiquidCrystal_I2C.h:55:7: note: candidate expects 1 argument, 8 provided
F:\Arduino\libraries\LiquidCrystal_I2C-master/LiquidCrystal_I2C.h:55:7: note: candidate: constexpr LiquidCrystal_I2C::LiquidCrystal_I2C(LiquidCrystal_I2C&&)
F:\Arduino\libraries\LiquidCrystal_I2C-master/LiquidCrystal_I2C.h:55:7: note: candidate expects 1 argument, 8 provided
exit status 1
'lcd' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
دیدگاه