Password Project

Hi, I’m trying to create a project where I can use buttons connected to pins 0-5 to enter a password into the board which will then be displayed on the screen. This will then eventually be able to read whether a correct or incorrect password has been entered, but my code keeps throwing up an error: expected declaration before ‘}’ token message. Can anyone help me out?!
Evidently, I’m pretty new to coding, so layman’s terms would be greatly appreciated!
I’ve attached my code, but I’ll print it below as well.

Thank you

#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 9, 17, 10, 11, 12, 13);

#define enable 15 //output enable pin for switch buffer
int a = 0;
int b = 1;
int c = 2;
int d = 3;
int e = 4;
int f = 5;

void setup() {

//set up number of rows and columns on LCD
lcd.begin(20, 4);
lcd.print(“Enter Code”);
}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

void loop()
{
read_switches();
//print message to screen defining whether pass word is right or not using if

if(a!=1 && a!=2 && a!=4 && a!=8 && a!=16 && a!=32) // if nothing is pressed, do nothing
{
}
else {
if(a==16) // but if second button is pressed, print “"
{
lcd.print("
”); // “2”
}

else{
lcd.print(“Invalid Password”); // otherwise display “Incorrect Password”
delay(600);
lcd.clear();
}
}

if(b!=1 && b!=2 && b!=4 && b!=8 && b!=16 && b!=32) // if nothing is pressed, do nothing
{
}
else {
if(b==1)
{
lcd.print("*"); // “6”
}
}

if(c!=1 && c!=2 && c!=4 && c!=8 && c!=16 && c!=32) // if nothing is pressed, do nothing
{
}
else {
if(c==2)
{
lcd.print("*"); // “5”
}
}

if(d!=1 && d!=2 && d!=4 && d!=8 && d!=16 && d!=32) // if nothing is pressed, do nothing
{
}
else {
if(d==8)
{
lcd.print("*"); // “3”
}
}

if(e!=1 && e!=2 && e!=4 && e!=8 && e!=16 && e!=32) // if nothing is pressed, do nothing
{
}
else {
if(e==32)
{
lcd.print("*"); // “1”
}
}

if(f!=1 && f!=2 && f!=4 && f!=8 && f!=16 && f!=32) // if nothing is pressed, do nothing
{
}
else {
if(f==4)
{
lcd.print("*"); // “4”
}
}
delay(200);
}
}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

byte read_switches()
{
byte portB_value;
pinMode(enable, OUTPUT);
DDRB = DDRB & B11000000; //set pins 0-5 as inputs
digitalWrite(enable, LOW); // enable the switches so they can be read
portB_value = PINB & B00111111; // read port B
digitalWrite(enable, HIGH); // disable the switches
DDRB = DDRB | B00111111; //set pins 0-5 as outputs

Serial.println(portB_value);
a=portB_value;
}//

AE2_assignment1.ino (2.02 KB)

You have two } at the end of loop(). That's one too many.

Thanks man! Just realised it throws up a load more error messages though. Damn.

Arduino: 1.6.3 (Windows 7), Board: "Arduino Duemilanove or Diecimila, ATmega328"

AE2_assignment.ino:3:18: error: redefinition of 'LiquidCrystal lcd'

AE2_assignment1.ino:3:15: error: 'LiquidCrystal lcd' previously declared here

AE2_assignment.ino: In function 'void setup()':

AE2_assignment.ino:8:6: error: redefinition of 'void setup()'

AE2_assignment1.ino:13:6: error: 'void setup()' previously defined here

AE2_assignment.ino: In function 'void loop()':

AE2_assignment.ino:16:6: error: redefinition of 'void loop()'

AE2_assignment1.ino:22:6: error: 'void loop()' previously defined here

AE2_assignment.ino: In function 'byte read_switches()':

AE2_assignment.ino:57:7: error: redefinition of 'byte read_switches()'

AE2_assignment1.ino:99:7: error: 'byte read_switches()' previously defined here

Error compiling.

There is a post, at the top of the page, that tells you how to use the forum. In other words, forum etiquette.

If you'd read that (I know there's a lot to it. I took me a few times to work through it), and followed the guidance offered, you may have actually spotted what was wrong. So, to cut a long story short - read it, and use code tags on formatted code.

I'm surprised it compiled with the extra periods.

I removed the extra curly brace, and the code compiled. You must have done something else. Post your revised code, correctly this time.

Is this your code?