Go Down

Topic: modified keypad lock (Read 125 times) previous topic - next topic

randomness175

Code: [Select]
So I've been trying to make a keypad lock for my room but I can't figure out the code if anyone has any suggestions on how to fix the code because I keep getting error messages(I'm going to put the error messages below the code)


[#include <LiquidCrystal.h>
LiquidCrystal lcd(12,13,14,15,16); // pin conversions 12=12,13=11,14=10,15=5,16=4
#include <Servo.h>
int led1Pin = 13;  //Green LED
int led2Pin = 12;  //Blue LED
int b4Pin = 5;
int b5Pin = 6;
int b6Pin = 7;
int b7Pin = 8;
int b8Pin = 9;
int b9Pin = 10;
int inputArray(10);
int(b0Pin) = 11;
int randomArray(10);
byte combonation[] = {7,3,5,1,9,4,0};
byte userInput[7];
boolean flag = true;

void setup() {
  // put your setup code here, to run once:
  (byte = 0; n < 7 ; n++)
  if (userInput[n] ! = combination[n]
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalRead userInput[n] = true;
  digitalWrite led2Pin == HIGH
  else led2Pin == LOW
  lcd.clear()
  lcd.setCursor(1,0)
  lcd.print(WELCOME)
  delay(100)
  lcd.clear()
  serco.attach(17)
  servo.write(180) //test may also be 0 b/c 90 is in the middle so 180 may be left or right idk
  servo.detach(17)
  {
    flag = false;
    if false digitalWrite led1Pin == HIGH
    else led1Pin == LOW
    lcd.clear()
    lcd.setCursor(1,0)
    lcd.print(WELCOME)
    delay(100)
    lcd.clear()
  }
}
]


I'm sorry if I did the code wrong

ERROR messages:
Arduino: 1.6.5 (Windows 8.1), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

button_game_thing:4: error: no matching function for call to 'LiquidCrystal::LiquidCrystal(int, int, int, int, int)'
button_game_thing.ino:4:33: note: candidates are:
In file included from button_game_thing.ino:3:0:
C:\Users\siarr_000\Downloads\arduino-1.6.5-r2-windows\arduino-1.6.5-r2\libraries\LiquidCrystal\src/LiquidCrystal.h:55:3: note: LiquidCrystal::LiquidCrystal(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)
   LiquidCrystal(uint8_t rs, uint8_t enable,
   ^
C:\Users\siarr_000\Downloads\arduino-1.6.5-r2-windows\arduino-1.6.5-r2\libraries\LiquidCrystal\src/LiquidCrystal.h:55:3: note:   candidate expects 6 arguments, 5 provided
C:\Users\siarr_000\Downloads\arduino-1.6.5-r2-windows\arduino-1.6.5-r2\libraries\LiquidCrystal\src/LiquidCrystal.h:53:3: note: LiquidCrystal::LiquidCrystal(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)
   LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
   ^
C:\Users\siarr_000\Downloads\arduino-1.6.5-r2-windows\arduino-1.6.5-r2\libraries\LiquidCrystal\src/LiquidCrystal.h:53:3: note:   candidate expects 7 arguments, 5 provided
C:\Users\siarr_000\Downloads\arduino-1.6.5-r2-windows\arduino-1.6.5-r2\libraries\LiquidCrystal\src/LiquidCrystal.h:50:3: note: LiquidCrystal::LiquidCrystal(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)
   LiquidCrystal(uint8_t rs, uint8_t rw, uint8_t enable,
   ^
C:\Users\siarr_000\Downloads\arduino-1.6.5-r2-windows\arduino-1.6.5-r2\libraries\LiquidCrystal\src/LiquidCrystal.h:50:3: note:   candidate expects 11 arguments, 5 provided
C:\Users\siarr_000\Downloads\arduino-1.6.5-r2-windows\arduino-1.6.5-r2\libraries\LiquidCrystal\src/LiquidCrystal.h:47:3: note: LiquidCrystal::LiquidCrystal(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)
   LiquidCrystal(uint8_t rs, uint8_t enable,
   ^
C:\Users\siarr_000\Downloads\arduino-1.6.5-r2-windows\arduino-1.6.5-r2\libraries\LiquidCrystal\src/LiquidCrystal.h:47:3: note:   candidate expects 10 arguments, 5 provided
C:\Users\siarr_000\Downloads\arduino-1.6.5-r2-windows\arduino-1.6.5-r2\libraries\LiquidCrystal\src/LiquidCrystal.h:45:7: note: LiquidCrystal::LiquidCrystal(const LiquidCrystal&)
 class LiquidCrystal : public Print {
       ^
C:\Users\siarr_000\Downloads\arduino-1.6.5-r2-windows\arduino-1.6.5-r2\libraries\LiquidCrystal\src/LiquidCrystal.h:45:7: note:   candidate expects 1 argument, 5 provided
button_game_thing.ino: In function 'void setup()':
button_game_thing:23: error: expected primary-expression before '=' token
button_game_thing:23: error: expected ')' before ';' token
button_game_thing:23: error: 'n' was not declared in this scope
button_game_thing:23: error: expected ';' before ')' token
button_game_thing.ino: In function 'void loop()':
button_game_thing:29: error: expected ';' before 'userInput'
button_game_thing:30: error: expected ';' before 'led2Pin'
no matching function for call to 'LiquidCrystal::LiquidCrystal(int, int, int, int, int)'

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
I'm sorry about the chaotic error messages and well just the format in general. This is the first time I'm ever using any kind of forum.

johnwasser

You are passing 5 pin numbers when you create the lcd object.  You need to pass 6, 7, 10, or 11 pin numbers.

You also seem to be using pins 12 and 13 for both LEDs and the LCD.  You can't generally use a single pin for two purposes.

Are you using an Arduino UNO?  If not you may find that Pins 14, 15, and 16 aren't where you think they are.  Use the names A0, A1, and A2 if you want the sketch to work on both an UNO and Leonardo.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

Delta_G

Code: [Select]

void setup() {
  // put your setup code here, to run once:
  (byte = 0; n < 7 ; n++)
  if (userInput[n] ! = combination[n]
}


Is that all there is to the setup function?

You forgot the for at the beginning of the for loop and you didn't give the byte variable a name.  Should be

Code: [Select]

  for (byte  n = 0; n < 7 ; n++)


Then you have an empty if statement that is missing it's final parenthesis.  If those things are not equal, then do what?  There's no sense in testing all those elements if you're not going to take any action on it. 
Ad hoc, ad loc, and quid pro quo.  So little time - so much to know!  ~Jeremy Hillary Boob Ph.D

Delta_G

At the beginning of loop()

Code: [Select]

void loop() {
  // put your main code here, to run repeatedly:
  digitalRead userInput[n] = true;


n is from the setup function.  It doesn't exist outside of that for loop.  It is undefined here and will throw an error for trying to use a variable that doesn't exist.

You also seem to have missed out on the fact that in C all statements end with a semicolon.  You have left that off of a number of lines. 

You should probably study up a little on C and C++ syntax and structure and work on some basic examples before you try to write larger code.  This is like trying to write a novel in Spanish when the only words you know are hola and adios. 
Ad hoc, ad loc, and quid pro quo.  So little time - so much to know!  ~Jeremy Hillary Boob Ph.D

Delta_G

Code: [Select]

if false digitalWrite led1Pin == HIGH
    else led1Pin == LOW


What's that supposed to be? 
Ad hoc, ad loc, and quid pro quo.  So little time - so much to know!  ~Jeremy Hillary Boob Ph.D

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy