Code Help Please

Hi, I am making a prop explosive for paintball but the code wont work. Please help if you can.
Thanks.

/Airsoft Bomb
Version 1.1Creators:
Chase Cooley&&&&&&&&&&&&
Joey Meyer
/

#include <Keypad.h>#include <LiquidCrystal.h>
#include <Tone.h>
#define pound 14
Tone tone1;int Scount = 0; // count seconds
int Mcount = 0; // count minutesint Hcount =0; // count hours
int Dcount = 0; // count daysint val = 0;
long secMillis = 0; // store last time for second addlong interval = 1000; // interval for seconds
char password[4];int currentLength = 0;
int i = 0;char entered[4];
int ledPin = 3; //red lightint ledPin2 = 4; //green light

LiquidCrystal lcd(7,8,10,11,12,13);const byte ROWS = 4; //four rows
const byte COLS = 3; //three columnschar keys[ROWS][COLS] = {
{'1','2','3'},{'4','5','6'},
{'7','8','9'},{'*','0','#'}
};
byte rowPins[ROWS] = {18, 2, 14, 16}; //connect to the row pinouts of the keypadbyte colPins[COLS] = {17, 19, 15}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup(){
pinMode(ledPin, OUTPUT); // sets the digital pin as outputpinMode(ledPin2, OUTPUT); // sets the digital pin as output
tone1.begin(9);lcd.begin(16, 2);
Serial.begin(9600);lcd.clear();
lcd.setCursor(0,0);lcd.print("Enter Code: ");
while (currentLength < 4){
lcd.setCursor(currentLength + 6, 1);lcd.cursor();
char key = keypad.getKey();key == NO_KEY;
if (key != NO_KEY){
lcd.print(key);password[currentLength] = key;
currentLength++;delay(200);
}}
if (currentLength == 4){
lcd.noCursor();lcd.clear();
lcd.home();lcd.print("You've Entered: ");
lcd.setCursor(6,1);lcd.print(password[0]);
lcd.print(password[1]);lcd.print(password[2]);
lcd.print(password[3]);delay(3000);
lcd.clear();currentLength = 0;
}}

void loop(){
char key2 = keypad.getKey(); // get the keylcd.setCursor(0,0);
timer();if (key2 != NO_KEY)
{while (key2 == NO_KEY)
{key2 = keypad.getKey();
}if (key2 != NO_KEY)
{lcd.clear();
lcd.setCursor(0,0);lcd.print("Enter Code: ");
while (currentLength < 4){
lcd.setCursor(currentLength + 6, 1);lcd.cursor();
char key2 = keypad.getKey();if (key2 != NO_KEY)
{lcd.print(key2);
entered[currentLength] = key2;currentLength++;
delay(200);lcd.noCursor();
lcd.setCursor(currentLength + 5, 1);lcd.print("*");
lcd.setCursor(currentLength + 6, 1);lcd.cursor();
}}
if (currentLength == 4){
if (entered[0] == password[0] && entered[1] == password[1] && entered[2] == password[2] && entered[3] == password[3]){
lcd.noCursor();lcd.clear();
lcd.home();lcd.print(" Defused ");
currentLength = 0;delay(2500);
lcd.setCursor(0,1);lcd.print("Reset the Bomb");
}else
{lcd.noCursor();
lcd.clear();lcd.home();
lcd.print(" Wrong ");lcd.setCursor(0,1);
lcd.print(" Add - 1:30 ");if (Mcount < 14)
{Mcount = Mcount + 1;
}if (Scount < 59)
{Scount = Scount + 30;
}delay(1500);
currentLength = 0;}
}}
}}

void timer(){
if ( Mcount >= 15 ){
while ( Mcount >= 15){
lcd.noCursor();lcd.clear();
lcd.home();lcd.print(" !BoOm! ");
tone1.play(NOTE_A2, 200);digitalWrite(ledPin, HIGH); // sets the LED on
tone1.play(NOTE_A2, 200);delay(10); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED offtone1.play(NOTE_A2, 200);
delay(10); // waits for a seconddigitalWrite(ledPin2, HIGH); // sets the LED on
tone1.play(NOTE_A2, 200);delay(10); // waits for a second
digitalWrite(ledPin2, LOW); // sets the LED offtone1.play(NOTE_A2, 200);
delay(10); // waits for a secondchar key4 = keypad.getKey();
if (key4 != NO_KEY){
while (key4 == NO_KEY){
key4 = keypad.getKey();}
if (key4 = '#'){
lcd.clear();lcd.print("Reset the Bomb");
}}
}if ( Mcount == 60) // if Mcount is 60 do this operation
{//delay (32); // good place to fine tune timing
Mcount = 0; // reset McountHcount ++;
}if (Hcount> 23)
{Dcount++;
Hcount = 0; // have to reset Hcount to "0" after 24hrs}

lcd.setCursor (0,1); // sets cursor to 2nd linelcd.print ("Timer: ");
lcd.print (Dcount);lcd.print (":");
lcd.print (Hcount);lcd.print (":");
lcd.print (Mcount);lcd.print (":");
lcd.print (Scount);
if (Scount >59) // if 60 do this operation{
Mcount ++; // add 1 to McountScount = 0; // reset Scount
//delay (58); // changes ms per min}
if (Scount < 60) // do this oper. 59 times{
unsigned long currentMillis = millis();//delay (988); // changing by one = 60 ms a min
if(currentMillis - secMillis > interval){
tone1.play(NOTE_G5, 200);secMillis = currentMillis;
Scount ++; // add 1 to ScountdigitalWrite(ledPin2, HIGH); // sets the LED on
delay(10); // waits for a seconddigitalWrite(ledPin2, LOW); // sets the LED off
delay(10); // waits for a second}
}}

but the code wont work.

That's a shame.
Neither did the code tags.

const byte COLS = 3; //three columnschar keys[ROWS][COLS] = {
{'1','2','3'},{'4','5','6'},
{'7','8','9'},{'*','0','#'}
};

Interesting construct.

AWOL:
That's a shame.
Neither did the code tags.

const byte COLS = 3; //three columnschar keys[ROWS][COLS] = {

{'1','2','3'},{'4','5','6'},
{'7','8','9'},{'*','0','#'}
};



Interesting construct.

Im sorry, what are code tags please? I'm fairly new to Arduino and just want to get this project working, but it keeps giving me error messages when I compile

but it keeps giving me error messages when I compile

But you didn't think it necessary to share them?

You said it wasn't working, not that it wasn't compiling.

AWOL:
But you didn't think it necessary to share them?

You said it wasn't working, not that it wasn't compiling.

Ok, here are the error messages.
Thanks.

Arduino: 1.5.8 (Mac OS X), Board: "Arduino Uno"

sketch_feb28a.ino:32:1: error: expected unqualified-id before '{' token
sketch_feb28a.ino:32:16: error: expected unqualified-id before ',' token
sketch_feb28a.ino:32:18: error: expected unqualified-id before '{' token
sketch_feb28a.ino:32:33: error: expected unqualified-id before ',' token
sketch_feb28a.ino:33:1: error: expected unqualified-id before '{' token
sketch_feb28a.ino:33:16: error: expected unqualified-id before ',' token
sketch_feb28a.ino:33:18: error: expected unqualified-id before '{' token
sketch_feb28a.ino:34:1: error: expected declaration before '}' token
Error compiling.

Have another close look at reply #1

Hi,

If you are posting code or error messages, use "code" tags: How to use this forum - please read. - Installation & Troubleshooting - Arduino Forum

Tom..... :slight_smile:

Interesting, but unreadable, code formatting. You really need to learn to format your code properly. If you format better the errors will be much easier to fix.

Im sorry, what are code tags please?

You failed to read #7 below:

http://forum.arduino.cc/index.php/topic,148850.0.html

Hi,

  • Can you please tell us what you are aiming to achieve?
  • What does the paintball bomb do?
  • What is the keypad supposed to do?
  • What is the display supposed to show?
  • What does the tone output do/indicate?

Did you write the sketch, have you tried to write all of it at once?
You need to write your sketch in sections, getting each section working, BEFORE attempting to program the next.

Tom.. A good project of the arduino...... :slight_smile:

TomGeorge:
Hi,

  • Can you please tell us what you are aiming to achieve?
  • What does the paintball bomb do?
  • What is the keypad supposed to do?
  • What is the display supposed to show?
  • What does the tone output do/indicate?

Did you write the sketch, have you tried to write all of it at once?
You need to write your sketch in sections, getting each section working, BEFORE attempting to program the next.

Tom.. A good project of the arduino...... :slight_smile:

Hi, I found the code here: http://www.instructables.com/id/Prop-bomb/step5/Uploading-the-code/
It's only meant to beep if the time runs out or if an incorrect code is entered.
Thanks

Instructables! :astonished: