Soooo, I've just made this piece if code for an uno, it's a door lock. it doesn't compile because of a series of errors--
/home/lakshya/Downloads/locky/locky.ino:18:82: error: no matching function for call to 'Keypad::Keypad(char*, <brace-enclosed initializer list>, <brace-enclosed initializer list>, const byte&, const byte&)'
Keypad* keypad = Keypad(makeKeymap(key), {9, 8, 7, 6 },{ 5, 4, 3, 2 }, rows, cols);
^
In file included from /home/lakshya/Downloads/locky/locky.ino:3:0:
/home/lakshya/Arduino/libraries/Keypad/src/Keypad.h:78:2: note: candidate: Keypad::Keypad(char*, byte*, byte*, byte, byte)
Keypad(char *userKeymap, byte *row, byte *col, byte numRows, byte numCols);
^~~~~~
/home/lakshya/Arduino/libraries/Keypad/src/Keypad.h:78:2: note: no known conversion for argument 2 from '<brace-enclosed initializer list>' to 'byte* {aka unsigned char*}'
/home/lakshya/Arduino/libraries/Keypad/src/Keypad.h:75:7: note: candidate: constexpr Keypad::Keypad(const Keypad&)
class Keypad : public Key {
^~~~~~
/home/lakshya/Arduino/libraries/Keypad/src/Keypad.h:75:7: note: candidate expects 1 argument, 5 provided
/home/lakshya/Arduino/libraries/Keypad/src/Keypad.h:75:7: note: candidate: constexpr Keypad::Keypad(Keypad&&)
/home/lakshya/Arduino/libraries/Keypad/src/Keypad.h:75:7: note: candidate expects 1 argument, 5 provided
/home/lakshya/Downloads/locky/locky.ino:19:18: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
char* password = "4567";
^~~~~~
/home/lakshya/Downloads/locky/locky.ino: In function 'void loop()':
/home/lakshya/Downloads/locky/locky.ino:45:22: error: request for member 'getKey' in 'keypad', which is of pointer type 'Keypad*' (maybe you meant to use '->' ?)
char code = keypad.getKey();
^~~~~~
Multiple libraries were found for "LiquidCrystal_I2C.h"
Used: /home/lakshya/Arduino/libraries/LiquidCrystal_I2C
Not used: /home/lakshya/Arduino/libraries/Arduino-LiquidCrystal-I2C-library-master
Using library Keypad at version 3.1.0 in folder: /home/lakshya/Arduino/libraries/Keypad
Using library LiquidCrystal I2C at version 1.1.2 in folder: /home/lakshya/Arduino/libraries/LiquidCrystal_I2C
Using library Wire at version 1.0 in folder: /home/lakshya/.arduino15/packages/arduino/hardware/avr/1.8.6/libraries/Wire
exit status 1
Compilation error: no matching function for call to 'Keypad::Keypad(char*, <brace-enclosed initializer list>, <brace-enclosed initializer list>, const byte&, const byte&)'
Yes, It's long, but i figured you'd need complete info to debug dis.
this is my code-
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
int pos = 0; // LCD Connections
const byte rows = 4;
const byte cols = 3;
char key[rows][cols] = {
{ '1', '2', '3' },
{ '4', '5', '6' },
{ '7', '8', '9' },
{ '*', '0', '#' }
};
Keypad* keypad = Keypad(makeKeymap(key), {9, 8, 7, 6 },{ 5, 4, 3, 2 }, rows, cols);
char* password = "4567";
int currentposition = 0;
int redled = 10;
int greenled = 11;
int buzz = 8;
int invalidcount = 12;
LiquidCrystal_I2C lcd(0x3F, 16, 2); // I2C address 0x27, 16 column and 2 rows
void setup() {
displayscreen();
Serial.begin(9600);
pinMode(redled, OUTPUT);
pinMode(greenled, OUTPUT);
pinMode(buzz, OUTPUT);
lcd.begin(16, 2);
}
void loop() {
if (currentposition == 0) {
displayscreen();
}
int l;
char code = keypad.getKey();
if (code != NO_KEY) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("PASSWORD:");
lcd.setCursor(7, 1);
lcd.print(" ");
lcd.setCursor(7, 1);
for (l = 0; l <= currentposition; ++l) {
lcd.print("*");
keypress();
}
if (code == password[currentposition]) {
++currentposition;
if (currentposition == 4) {
unlockdoor();
currentposition = 0;
}
}
else {
++invalidcount;
incorrect();
currentposition = 0;
}
if (invalidcount == 5) {
++invalidcount;
torture1();
}
if (invalidcount == 8) {
torture2();
}
}
// LOOP ENDS!!!//
}
//********OPEN THE DOOR FUNCTION!!!!***********//
void unlockdoor() {
delay(900);
lcd.setCursor(0, 0);
lcd.println(" ");
lcd.setCursor(1, 0);
lcd.print("Access Granted");
lcd.setCursor(4, 1);
lcd.println("WELCOME!!");
lcd.setCursor(15, 1);
lcd.println(" ");
lcd.setCursor(16, 1);
lcd.println(" ");
lcd.setCursor(14, 1);
lcd.println(" ");
lcd.setCursor(13, 1);
lcd.println(" ");
unlockbuzz();
digitalWrite(13,HIGH);
delay(2000);
delay(1000);
counterbeep();
delay(1000);
digitalWrite(13,LOW);
currentposition = 0;
lcd.clear();
displayscreen();
}
//************WRONG CODE FUNCTION********//
void incorrect() {
delay(500);
lcd.clear();
lcd.setCursor(1, 0);
lcd.print("CODE");
lcd.setCursor(6, 0);
lcd.print("INCORRECT");
lcd.setCursor(15, 1);
lcd.println(" ");
lcd.setCursor(4, 1);
lcd.println("GET AWAY!!!");
lcd.setCursor(13, 1);
lcd.println(" ");
Serial.println("CODE INCORRECT YOU ARE UNAUTHORIZED");
digitalWrite(redled, HIGH);
digitalWrite(buzz, HIGH);
delay(3000);
lcd.clear();
digitalWrite(redled, LOW);
digitalWrite(buzz, LOW);
displayscreen();
}
//************** CLEAR THE SCREEN!!!*************//
void clearscreen() {
lcd.setCursor(0, 0);
lcd.println(" ");
lcd.setCursor(0, 1);
lcd.println(" ");
lcd.setCursor(0, 2);
lcd.println(" ");
lcd.setCursor(0, 3);
lcd.println(" ");
}
//**************KEYPRESS********************//
void keypress() {
digitalWrite(buzz, HIGH);
delay(50);
digitalWrite(buzz, LOW);
}
//********DISPALAY FUNCTION!!!*************//
void displayscreen() {
lcd.setCursor(0, 0);
lcd.print("Don't even try,");
lcd.setCursor(0, 1);
lcd.print("CHINTU");
}
//*************** ARM SERVO***********//
void armservo() {
digitalWrite(10,HIGH);
delay(5000);
digitalWrite(10,HIGH);
}
//**********UNLOCK BUZZ*************//
void unlockbuzz() {
digitalWrite(buzz, HIGH);
delay(80);
digitalWrite(buzz, LOW);
delay(80);
digitalWrite(buzz, HIGH);
delay(80);
digitalWrite(buzz, LOW);
delay(200);
digitalWrite(buzz, HIGH);
delay(80);
digitalWrite(buzz, LOW);
delay(80);
digitalWrite(buzz, HIGH);
delay(80);
digitalWrite(buzz, LOW);
delay(80);
}
//**********COUNTER BEEP**********//
void counterbeep() {
delay(1200);
lcd.clear();
digitalWrite(buzz, HIGH);
lcd.setCursor(2, 15);
lcd.println(" ");
lcd.setCursor(2, 14);
lcd.println(" ");
lcd.setCursor(2, 0);
delay(200);
lcd.println("GET IN WITHIN:::");
lcd.setCursor(4, 1);
lcd.print("5");
delay(200);
lcd.clear();
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
digitalWrite(buzz, LOW);
delay(1000);
//2
digitalWrite(buzz, HIGH);
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
lcd.setCursor(4, 1); //2
lcd.print("4");
delay(100);
lcd.clear();
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
digitalWrite(buzz, LOW);
delay(1000);
//3
digitalWrite(buzz, HIGH);
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
lcd.setCursor(4, 1); //3
lcd.print("3");
delay(100);
lcd.clear();
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
digitalWrite(buzz, LOW);
delay(1000);
//4
digitalWrite(buzz, HIGH);
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
lcd.setCursor(4, 1); //4
lcd.print("2");
delay(100);
lcd.clear();
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN:");
digitalWrite(buzz, LOW);
delay(1000);
//
digitalWrite(buzz, HIGH);
lcd.setCursor(4, 1);
lcd.print("1");
delay(100);
lcd.clear();
lcd.setCursor(2, 0);
lcd.println("GET IN WITHIN::");
digitalWrite(buzz, LOW);
delay(1000);
//5
digitalWrite(buzz, HIGH);
delay(40);
digitalWrite(buzz, LOW);
delay(40);
digitalWrite(buzz, HIGH);
delay(40);
digitalWrite(buzz, LOW);
delay(40);
digitalWrite(buzz, HIGH);
delay(40);
digitalWrite(buzz, LOW);
delay(40);
digitalWrite(buzz, HIGH);
delay(40);
digitalWrite(buzz, LOW);
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("RE-LOCKING");
delay(500);
lcd.setCursor(12, 0);
lcd.print(".");
delay(500);
lcd.setCursor(13, 0);
lcd.print(".");
delay(500);
lcd.setCursor(14, 0);
lcd.print(".");
delay(400);
lcd.clear();
lcd.setCursor(4, 0);
lcd.print("LOCKED!");
delay(440);
}
//*********TORTURE1***********//
void torture1() {
delay(1000);
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("WAIT FOR ");
lcd.setCursor(5, 1);
lcd.print("15 SECONDS");
digitalWrite(buzz, HIGH);
delay(15000);
digitalWrite(buzz, LOW);
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("LOL..");
lcd.setCursor(1, 1);
lcd.print(" HOW WAS THAT??");
delay(3500);
lcd.clear();
}
//*****TORTURE2*****//
void torture2() {
delay(1000);
lcd.setCursor(1, 0);
lcd.print(" ");
lcd.setCursor(2, 0);
lcd.print("EAR DRUMS ARE");
lcd.setCursor(0, 1);
lcd.print(" PRECIOUS!! ");
delay(1500);
lcd.clear();
lcd.setCursor(1, 0);
lcd.print(" WAIT FOR");
lcd.setCursor(4, 1);
lcd.print(" 1 MINUTE");
digitalWrite(buzz, HIGH);
delay(55000);
counterbeep();
lcd.clear();
digitalWrite(buzz, LOW);
lcd.setCursor(2, 0);
lcd.print("WANT MORE");
lcd.setCursor(1, 1);
lcd.print("DEAR BROTHER?");
delay(2500);
lcd.clear();
lcd.setCursor(2, 0);
lcd.print("Ha Ha Ha Ha");
delay(1700);
lcd.clear();
}
So, yeah, that's my problem