indeed i did some corrections while posting....
i declared the key1 and key3 as global vars and solved the error that gave me but i have run to some others as well
it's my first ardu program so please bear with me....
the errors
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows NT (unknown)), Board: "Arduino Uno"
i_pomba:19: error: variable or field 'timer1' declared void
i_pomba:19: error: 'max_arm' was not declared in this scope
i_pomba.ino: In function 'void loop()':
i_pomba:135: error: 'timer1' was not declared in this scope
i_pomba.ino: At global scope:
i_pomba:138: error: variable or field 'timer1' declared void
Aaaaand the whole code so far:
/*
Defusable Paintball Bomb:
Made by Vangelis Moutafis
Keypad lay out:
1 2 3
4 5 6
7 8 9
* 0 #
*/
#include <Keypad.h>
#include <LiquidCrystal.h>
#include <Tone.h>
#define pound 14
Tone tone1;
int max_arm;//hronos arm
int max_darm;//hronos disarm
int Scount=0;
char key1;
char key3;
long scMillis=0;//apo8ikefsi telefteou hronou gia 2i pros8esi
long interval=1000;//gia lepta
char pass[4];
int currentLength=0;//poios apo tous ari8mus grafetai
int i=0;
char entered[4];
int ledPin=2;//Yellow led
int ledPin2=3;//Red led
LiquidCrystal lcd(7,8,10,11,12,13);// pins tis lcd
//Gia to keypad
const byte ROWS=4;
const byte COLS=3;
char keys[ROWS][COLS]={
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS]={5,A5,A4,A2};//ta pins pou en gia tis grammes
byte colPins[COLS]={A1,A0,A3};//ta pins pou en gia tis stiles
Keypad keypad=Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup(){
pinMode(ledPin, OUTPUT);//kamei to pin 2 san output
pinMode(ledPin2, OUTPUT);//kamei to pin 3 san output
tone1.begin(9);
lcd.begin(16,2);//16x2 haraktires lcd
Serial.begin(9600);//tahitia metadwsis meta3i arduinu j lcd
lcd.clear();
lcd.setCursor(0,0);
//Posos enna o hronos gia na tin kamun arm
max_arm=1;
do
{
lcd.print("Arm Time: ");
lcd.print(max_arm);
lcd.print("min");
key1=keypad.getKey();
lcd.cursor();
key1 == NO_KEY;
if(key1!=NO_KEY)
{
if(key1=='2')
max_arm++;
if(key1=='8')
max_arm--;
}
lcd.clear();
lcd.setCursor(0,0);
}while(key1 != '5');
//Posos hronos gia disarm:
max_darm=1;
do
{
lcd.print("Dsrm Time: ");
lcd.print(max_darm);
lcd.print("min");
key3=keypad.getKey();
lcd.cursor();
key3==NO_KEY;
if(key3!=NO_KEY)
{
if(key3=='2')
max_darm++;
if(key3=='8')
max_darm--;
}
lcd.clear();
lcd.setCursor(0,0);
}while(key3!='5');
//Gia na men kamume kamia malakia me ton kwdiko chakarw an t evalame swsta
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)
{
if ((key!='*')&&(key!='#'))
{
lcd.print(key);
currentLength++;
tone1.play(NOTE_C6,200);
}
}
}
if (currentLength == 4)
{
delay(500);
lcd.noCursor();
lcd.home();
lcd.print("You've Entered: ");
lcd.setCursor(6,1);
lcd.print(pass[0]);
lcd.print(pass[1]);
lcd.print(pass[2]);
lcd.print(pass[3]);
tone1.play(NOTE_E6,200);
delay(3000);
lcd.clear();
currentLength=0;
}
}
void loop(){
timer1(max_arm);
}
void timer1(max_arm)
{
int Scount=0;
Serial.print(max_arm);
Serial.println();
if(max_arm<0)
{
lcd.noCursor();
lcd.Clear();
lcd.home();
lcd.print("BOOOOOOOOOM!!!!");
lcd.setCursor(0,1);
lcd.print("Bomb exploded");
while(max_arm)
{
digitalWrite(ledPin, HIGH); // sets the LED on
tone1.play(NOTE_A2, 90);
delay(100);
digitalWrite(ledPin, LOW); // sets the LED off
tone1.play(NOTE_A2, 90);
delay(100);
digitalWrite(ledPin2, HIGH); // sets the LED on
tone1.play(NOTE_A2, 90);
delay(100);
digitalWrite(ledPin2, LOW); // sets the LED off
tone1.play(NOTE_A2, 90);
delay(100);
}
}
lcd.setCursor(0,1);//2i grammi
lcd.print("Timer:");
if (max_arm >= 10)
{
lcd.setCursor (10,1);
lcd.print (Max_arm);
}
if (max_arm < 10)
{
lcd.setCursor (7,1);
lcd.write ("0");
lcd.setCursor (8,1);
lcd.print(max_arm);
}
lcd.print (":");
if (Scount >= 10)
{
lcd.setCursor (10,1);
lcd.print (Scount);
}
if (Scount < 10)
{
lcd.setCursor (10,1);
lcd.write ("0");
lcd.setCursor (11,1);
lcd.print (Scount);
}
if (Scount <1) // if 60 do this operation
{
max_arm--; // - 1 sta lepta
Scount = 59; // reset Scount
}
if (Scount > 0) // do this oper. 59 times
{
unsigned long currentMillis = millis();
if(currentMillis - secMillis > interval)
{
tone1.play(NOTE_G5, 200);
secMillis = currentMillis;
Scount --; // add 1 to Scount
digitalWrite(ledPin2, HIGH); // sets the LED on
delay(10); // waits for a second
digitalWrite(ledPin2, LOW); // sets the LED off
delay(10); // waits for a second
//lcd.clear();
}
}
if(max_arm==2)
digitalWrite(letPin2,HIGH);
if(max_arm==1){
digitalWrite(ledPin,HIGH);
digitalWrite(ledPin2,LOW);
}
}