Pages: 1 2 [3]   Go Down
Author Topic: Timer program  (Read 4930 times)
0 Members and 1 Guest are viewing this topic.
Fresno, CA, USA
Offline Offline
Full Member
***
Karma: 1
Posts: 153
Arduino rocks (literally, with a WaveShield!)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Scatter DEBUG_PRINT("I'm a smart coder!! smiley-grin"); all over your code.

From the looks of things, DEBUG_PRINT() is just a quick "switchable" way to turn those statements into either "Serial.println(...)" or "" (nothing) depending on if #DEBUG is turned on or off. Does the same thing as using Serial.println().

So, I dunno if I'm being too technical here or what, but it's the same thing we've been saying for the past 6 or 7 posts about "debugging"... you've just... got... to write... your own... debug code. It's not that (f#$%ing) hard, really it's not. Anywhere you want to know what's going on, or where that part of the code is messing up, write:

DEBUG_PRINT("HAPPY PEOPLE FURIOUSLY EAT SLEEPING COLORLESS GREEN IDEAS!");

... Or whatever is relevant to the code you're trying to debug. Then use Tools -> Serial Monitor, and watch what happens.
(Oh, you may also need a "Serial.begin(9600);" line in your Setup().)
« Last Edit: June 19, 2011, 02:25:10 pm by FalconFour » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 495
Posts: 19036
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Another technique, if your code is timing-dependent, is to use any spare pins to light LEDs.

Make up a little LED board or strip with a few LEDs with suitable series resistors (eg. 220 ohm). Then plug the LEDs into spare pins, configure them for output, and turn them on/off at various places in your code. Looks pretty too!

eg.

Code:
digitalWrite (13, HIGH);
do_something ();
digitalWrite (13, LOW);

So when the LED on pin 13 goes on, you know you are in do_something() function. If it stays on you know you are stuck there. If the LED never lights up you know you never got there (or perhaps so briefly you can't see it).

Here is an example of a board I made up on a small piece of prototyping board that does exactly that:



You plug the black wire into the Gnd pin, and the others into whatever pins you like. Then watch the light show as you test your program.

Sometimes it is faster to spend an hour making up a board like that, and seeing what is happening, then spend days trying to puzzle out what is wrong. And of course a board like that can be reused many times.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, I am busy constructing one . need to go get some parts today, I will keep you informed on the progress. smiley

Another technique, if your code is timing-dependent, is to use any spare pins to light LEDs.

Make up a little LED board or strip with a few LEDs with suitable series resistors (eg. 220 ohm). Then plug the LEDs into spare pins, configure them for output, and turn them on/off at various places in your code. Looks pretty too!

eg.

Code:
digitalWrite (13, HIGH);
do_something ();
digitalWrite (13, LOW);

So when the LED on pin 13 goes on, you know you are in do_something() function. If it stays on you know you are stuck there. If the LED never lights up you know you never got there (or perhaps so briefly you can't see it).

Here is an example of a board I made up on a small piece of prototyping board that does exactly that:



You plug the black wire into the Gnd pin, and the others into whatever pins you like. Then watch the light show as you test your program.

Sometimes it is faster to spend an hour making up a board like that, and seeing what is happening, then spend days trying to puzzle out what is wrong. And of course a board like that can be reused many times.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
Thanks again for all the help.

I dont mean to offend you guys, but I have never done coding before and I decided to do something with my son that he wants to do, I live in Africa and it took me 2 months to get the Arduino uno board and parts for this project. Then it was a process working out the components since it is not the same as the project due to availability. then the first Arduino board was faulty and the suppliers swoped it out (thanks for that). then I contact the manufacturers to get help with the code and they recomended you guys.
then when I asked for help I was treated as shit.
FalconFour, Awol and Nick found it in there good nature to help me ,I have never posted on forums before or done coding and I must say you guys are blady briliant at making people feel like crap.

I did the whole debug bug procedure and it means very little to me! all it prints in the serail screen is
(1434687: void loop() C:\Users\Adam\AppData\Local\Temp\build3797742604559976109.tmp\sketch_jun17a.cpp:103 I'm here!) The bomb is supposed to defuse not restart the timer.
And when I go to the line it is (lcd.setCursor(0, 1);.)


Scatter DEBUG_PRINT("I'm a smart coder!! smiley-grin"); all over your code.

From the looks of things, DEBUG_PRINT() is just a quick "switchable" way to turn those statements into either "Serial.println(...)" or "" (nothing) depending on if #DEBUG is turned on or off. Does the same thing as using Serial.println().

So, I dunno if I'm being too technical here or what, but it's the same thing we've been saying for the past 6 or 7 posts about "debugging"... you've just... got... to write... your own... debug code. It's not that (f#$%ing) hard, really it's not. Anywhere you want to know what's going on, or where that part of the code is messing up, write:

DEBUG_PRINT("HAPPY PEOPLE FURIOUSLY EAT SLEEPING COLORLESS GREEN IDEAS!");

... Or whatever is relevant to the code you're trying to debug. Then use Tools -> Serial Monitor, and watch what happens.
(Oh, you may also need a "Serial.begin(9600);" line in your Setup().)
« Last Edit: June 20, 2011, 01:37:32 am by soul1974 » Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 495
Posts: 19036
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, I am busy constructing one . need to go get some parts today, I will keep you informed on the progress. smiley

Ah, right. So there is no confusion, this is the circuit:



All resistors are the same, the value isn't particularly critical, but something around 200 ohms would be about right. Not too low or you might overload your processor.
Logged


Global Moderator
Offline Offline
Brattain Member
*****
Karma: 495
Posts: 19036
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I have never posted on forums before or done coding and I must say you guys are blady briliant at making people feel like crap.

Apart from the other seven? ...

Thanks again, you are the only one on 8 forums helping.

You might want to reconsider your attitude. Your posts are somewhat insulting ("you guys make people feel like crap"). You say you never posted before, but in fact you said you posted on 8 forums.

People generally try to help, if you clearly state the problem, state what you are trying to achieve, and what you have done so far.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Nick,

Thanks for your diagram I got it to work.
Quote
Apart from the other seven? ...
I have only posted on the forums for help within the last few weeks. sorry if this has to be a precise list of events leading to this day.


I have never posted on forums before or done coding and I must say you guys are blady briliant at making people feel like crap.

Apart from the other seven? ...

Thanks again, you are the only one on 8 forums helping.

You might want to reconsider your attitude. Your posts are somewhat insulting ("you guys make people feel like crap"). You say you never posted before, but in fact you said you posted on 8 forums.

People generally try to help, if you clearly state the problem, state what you are trying to achieve, and what you have done so far.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 308
Posts: 26474
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There are a few problems to be addressed here.

Netiquette:
You say you've posted on eight forums.
Now imagine how we'd feel here if you got an answer on one of those other forums, didn't post the result here, and just left us hanging, carrying on answering your posts.
We'd be wasting our time.

Debugging:
It is quite likely that no-one else has your exact hardware setup, or is willing to configure their kit to match.
So, you have to do a little work yourself.
Now, you've stitched together some code from somewhere, you don't fully understand how it all works (or doesn't) and then you want someone to dig you out of that hole.
Two approaches:
Break down the problem into components, like keypad entry, and concentrate on fully understanding how it all fits together. Write your own simple sketches, and print the results to just about the simplest I/O device on the Arduino, the Serial object.
Don't understand how the Serial object works?
Break it down into simpler sketches, try different things.


The second approach is to take your code as it is, put in debug statements at all the major decision points in the code, and then check that a run of the code matches where you think you think the code ought to go.
If it doesn't go where you think it should, examine the code and the inputs.

There are no shortcuts to learning to program (or debug), but a methodical approach always helps.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Awol,

Thanks for your reply, I have not gone on to the other forums again since I dont want to get confused with to many answers, I believe that the Arduino rep was correct in saying that this site is the best place to get help.
I have learned alot in these past few post from You and the rest of the User that have been helping me , If i had anything useful to post I would have done so, but as you can see I even mess up posting to this site.
I am working on a detailed description and images of the project and will post it here, I hope you and the rest can forgive my attitude as I apologise from the bottom of my bad code.

Thanks Again.

There are a few problems to be addressed here.

Netiquette:
You say you've posted on eight forums.
Now imagine how we'd feel here if you got an answer on one of those other forums, didn't post the result here, and just left us hanging, carrying on answering your posts.
We'd be wasting our time.

Debugging:
It is quite likely that no-one else has your exact hardware setup, or is willing to configure their kit to match.
So, you have to do a little work yourself.
Now, you've stitched together some code from somewhere, you don't fully understand how it all works (or doesn't) and then you want someone to dig you out of that hole.
Two approaches:
Break down the problem into components, like keypad entry, and concentrate on fully understanding how it all fits together. Write your own simple sketches, and print the results to just about the simplest I/O device on the Arduino, the Serial object.
Don't understand how the Serial object works?
Break it down into simpler sketches, try different things.


The second approach is to take your code as it is, put in debug statements at all the major decision points in the code, and then check that a run of the code matches where you think you think the code ought to go.
If it doesn't go where you think it should, examine the code and the inputs.

There are no shortcuts to learning to program (or debug), but a methodical approach always helps.
« Last Edit: June 20, 2011, 09:42:29 am by soul1974 » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

HI Guys,

Thanks for all your help again , I got the code to work with the hardware but I need to change a few options and was wondering if you were willing to help.

1. I need to have to set codes , 1 for arming the prop bomb and one for disarming the prop bomb.
2. How can I get the beeping sound and light to go faster as the time gets less till it detonates the prop bomb
3. I need the siren at the end to be more urgent sounding and longer lasting lets say 13 seconds or is there  away I can use a siren from a home alarm system.

Code:
/*Airsoft TIMER
 Version 1.5
Creators:
 Chase Cooley
 Joey Meyer
Turned into usable code, 6/16/2011:
 Matt Falcon*/

//#define DEBUG
//#include "DebugUtils.h"
#include <Keypad.h>
#include <LiquidCrystal.h>
#define pound 14
#define LED_RED 6
#define LED_GREEN 5
#define KP_ROWS 3
#define KP_COLS 4




unsigned int timerSeconds = 300; // start with 5 minutes on the clock
byte password[4];
byte entered[4];
int currentLength = 0;
byte i = 0;

LiquidCrystal lcd(8,7, 10, 11, 12, 13);


//Keypad
char keys[KP_ROWS][KP_COLS] = { { '1', '2', '3', '4' }, { '5', '6', '7', '8' }, {
'*', '9', '0', '#' } };
byte rowPins[KP_ROWS] = {2,14,15}; //connect to the row pinouts of the keypad
byte colPins[KP_COLS] = { 19,18,17,16 }; //connect to the column pinouts of the keypad
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, KP_ROWS, KP_COLS);

char key;

//LCD setup
void setup() {
  Serial.begin(9600);
pinMode(LED_RED, OUTPUT); // sets the digital pin as output
pinMode(LED_GREEN, OUTPUT); // sets the digital pin as output
lcd.begin(16, 2);
lcd.print("Enter Code: ");
lcd.cursor();
lcd.setCursor(6, 1);
while (currentLength < 4) {
key = keypad.getKey();
if (key != NO_KEY) {
lcd.print(key);
password[currentLength] = key;
currentLength++;
lcd.setCursor(currentLength + 6, 1);
} else delay(10); // only sample it every 1/10 sec, no need to go apesh!t
}
lcd.noCursor();
lcd.clear();
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(2500);
lcd.clear();
currentLength = 0;
}

void loop() {
lcd.clear();
lcd.print("Enter Code: ");
lcd.cursor();
key = keypad.getKey(); // get the key once per this loop
if (key != NO_KEY) {
lcd.setCursor(0, 1);
lcd.print("           ");
lcd.setCursor(6, 1);
while (currentLength < 4) {
// here, we take the key that broke us into this "if" statement, instead of discarding it. this also pauses the timer, effectively.
if (key != NO_KEY) { // redundant for the first loop, but necessary for every next character
lcd.setCursor(currentLength + 5, 1);
lcd.print(key);
entered[currentLength] = key;
currentLength++;
} else delay(10); // only sample it every 1/10 sec
key = keypad.getKey(); // get the key every time "while" loops
}
if (memcmp(entered,password,4) == 0) { // shortcut to compare an array of bytes, use memcmp(A, B, length), will return 0 if match.
lcd.noCursor();
lcd.clear();
lcd.print(" Defused ");
                         tone(9,1200, 4000); //
                         lcd.clear();
lcd.setCursor(0,0);
lcd.print("Bomb Rebooting");
                         lcd.setCursor(0,1 );
                         lcd.print("Have a nice day!");
                         delay(4000); // hold that on screen for 2.5 seconds
                         void (*softReset) (void) = 0; //declare reset function @ address 0
                         softReset();
                         lcd.clear();
currentLength = 0;
} else {
lcd.noCursor();
lcd.clear();
lcd.print(" Wrong ");
                         tone(9,110, 2500); 
lcd.setCursor(0, 1);
lcd.print("Penalty -2:00"); // Display time penalty
if (timerSeconds > 120) timerSeconds -= 120;
else timerSeconds = 1; // will trigger BOOM next cycle
currentLength = 0;
delay(2500); // hold that on screen for 2.5 seconds
                         lcd.clear();
}
}
timer(); // prints current time on screen, checks for "go off" time, holds loop for 1 second
}

void timer() {
lcd.setCursor(0, 1); // sets cursor to 2nd line
lcd.print("Timer: ");
lcd.print(timerSeconds / 60); // integer number of minutes on clock
lcd.print(":");
lcd.print(timerSeconds % 60); // mod 60; gives us number of seconds outside of 60sec/min
delay(950); // hold us here for 0.950 seconds
{
digitalWrite(LED_RED,!digitalRead(LED_RED)); // toggle the green LED once a second
}
tone(9,800, 250); // play bleep for 50ms
delay(50); // and there's the rest of that 1 second (not counting LCD delay)

timerSeconds--;
if (timerSeconds == 0) bombomb();
}
void bombomb() {
// routine for making ze BOMB GOEZ OFF!!!1 :D
lcd.noCursor();
lcd.clear();
lcd.print(" !BoOo0o0o0om! ");
         lcd.setCursor(0, 1);
         lcd.print("you LoSe Sucker!");
tone(9,110, 100);
digitalWrite(LED_RED, HIGH); // sets the red LED on
delay(500); // waits half a second
tone(9,110, 100);
delay(500); // waits half a second
digitalWrite(LED_RED, LOW); // sets the red LED off
digitalWrite(LED_GREEN, HIGH); // sets the green LED on
tone(9,110, 100);
delay(500); // waits half a second
digitalWrite(LED_RED, HIGH); // sets the red LED on
digitalWrite(LED_GREEN, LOW); // sets the green LED off
tone(9,110, 100);
delay(500); // waits half a second
digitalWrite(LED_RED, LOW); // sets the red LED off
digitalWrite(LED_GREEN, HIGH); // sets the green LED on
tone(9,110, 100);
delay(500); // waits half a second

key = NO_KEY; // enter the while() loop, otherwise it'll skip. i could use do { } while();, but I'm lazy.
{
while (key == NO_KEY) {
key = keypad.getKey();
if (key == '#') {
lcd.clear();
lcd.print("Resetting:");
                         lcd.setCursor(6,1);
                         lcd.print("the Bomb!");
delay(3000); //  3 sec delay
                          void (*softReset) (void) = 0; //declare reset function @ address 0
softReset();
//timerSeconds = 300; // put 5 minutes on the clock
// and we break the loop and go back to timer.
} else  key = NO_KEY; // continue looking for pound key
}
    }
}
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 308
Posts: 26474
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
                       void (*softReset) (void) = 0; //declare reset function @ address 0
                         softReset();
                         lcd.clear();
currentLength = 0;
What exactly do you expect to happen after calling "softReset"?

(The IDE has an auto-format tool - it is a good tool to use before posting code)
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It resets the Arduino, I have tried
Code:
setup();
but it has issues with the lights and the keypad
Code:
void (*softReset) (void) = 0; //declare reset function @ address 0
                         softReset();
                         lcd.clear();
currentLength = 0;
actual soft resets the Arduino
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 308
Posts: 26474
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
It resets the Arduino
So why have you got code after it?


(it doesn't actually reset the processor, but it is close enough for most purposes)
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry that is the wrong code here is the correct one ,I have to still delete the old ones.
Code:
/*Airsoft TIMER
 Version 1.5
 Creators:
 Chase Cooley
 Joey Meyer
 Turned into usable code, 6/16/2011:
 Matt Falcon*/

//#define DEBUG
//#include "DebugUtils.h"
#include <Keypad.h>
#include <LiquidCrystal.h>
#define pound 14
#define LED_RED 6
#define LED_GREEN 5
#define KP_ROWS 3
#define KP_COLS 4




unsigned int timerSeconds = 300; // start with 5 minutes on the clock
byte password[4];
byte entered[4];
int currentLength = 0;
byte i = 0;

LiquidCrystal lcd(8,7, 10, 11, 12, 13);


//Keypad
char keys[KP_ROWS][KP_COLS] = {
  {
    '1', '2', '3', '4'     }
  , {
    '5', '6', '7', '8'     }
  , {
    '*', '9', '0', '#'     }
};
byte rowPins[KP_ROWS] = {
  2,14,15}; //connect to the row pinouts of the keypad
byte colPins[KP_COLS] = {
  19,18,17,16 }; //connect to the column pinouts of the keypad
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, KP_ROWS, KP_COLS);

char key;

//LCD setup
void setup() {
  Serial.begin(9600);
  pinMode(LED_RED, OUTPUT); // sets the digital pin as output
  pinMode(LED_GREEN, OUTPUT); // sets the digital pin as output
  lcd.begin(16, 2);
  lcd.print("Enter Code: ");
  lcd.cursor();
  lcd.setCursor(6, 1);
  while (currentLength < 4) {
    key = keypad.getKey();
    if (key != NO_KEY) {
      lcd.print(key);
      password[currentLength] = key;
      currentLength++;
      lcd.setCursor(currentLength + 6, 1);
    }
    else delay(10);
  }
  lcd.noCursor();
  lcd.clear();
  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(2500);
  lcd.clear();
  currentLength = 0;
}

void loop() {
  lcd.clear();
  lcd.print("Enter Code: ");
  lcd.cursor();
  key = keypad.getKey(); // get the key once per this loop
  if (key != NO_KEY) {
    lcd.setCursor(0, 1);
    lcd.print("           ");
    lcd.setCursor(6, 1);
    while (currentLength < 4) {
      // here, we take the key that broke us into this "if" statement, instead of discarding it. this also pauses the timer, effectively.
      if (key != NO_KEY)
      { // redundant for the first loop, but necessary for every next character
        lcd.setCursor(currentLength + 5, 1);
        lcd.print(key);
        entered[currentLength] = key;
        currentLength++;
      }
      else delay(10);
      key = keypad.getKey(); // get the key every time "while" loops
    }
    if (memcmp(entered,password,4) == 0) { // shortcut to compare an array of bytes, use memcmp(A, B, length), will return 0 if match.
      lcd.noCursor();
      lcd.clear();
      lcd.print(" Defused ");
      tone(9,1200, 4000); //
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Bomb Rebooting");
      lcd.setCursor(0,1 );
      lcd.print("Have a nice day!");
      currentLength = 0;
      delay(4000); // hold that on screen for 2.5 seconds
      lcd.clear();
      currentLength = 0;
      setup();
    }
    else {
      lcd.noCursor();
      lcd.clear();
      lcd.print(" Wrong ");
      tone(9,110, 2500);  
      lcd.setCursor(0, 1);
      lcd.print("Penalty -2:00"); // Display time penalty
      if (timerSeconds > 120) timerSeconds -= 120;
      else timerSeconds = 1; // will trigger BOOM next cycle
      currentLength = 0;
      delay(2500); // hold that on screen for 2.5 seconds
      lcd.clear();
    }
  }
  timer(); // prints current time on screen, checks for "go off" time, holds loop for 1 second
}

void timer() {
  lcd.setCursor(0, 1); // sets cursor to 2nd line
  lcd.print("Timer: ");
  lcd.print(timerSeconds / 60); // integer number of minutes on clock
  lcd.print(":");
  lcd.print(timerSeconds % 60); // mod 60; gives us number of seconds outside of 60sec/min
  delay(950); // hold us here for 0.950 seconds
  {
    digitalWrite(LED_RED,!digitalRead(LED_RED)); // toggle the green LED once a second
  }
  tone(9,800, 250); // play bleep for 50ms
  delay(50); // and there's the rest of that 1 second (not counting LCD delay)

  timerSeconds--;
  if (timerSeconds == 0) bombomb();
}
void bombomb() {
  // routine for making ze BOMB GOEZ OFF!!!1 :D
  lcd.noCursor();
  lcd.clear();
  lcd.print(" !BoOo0o0o0om! ");
  lcd.setCursor(0, 1);
  lcd.print("you LoSe Sucker!");
  tone(9,110, 100);
  digitalWrite(LED_RED, HIGH); // sets the red LED on
  delay(500); // waits half a second
  tone(9,110, 100);
  delay(500); // waits half a second
  digitalWrite(LED_RED, LOW); // sets the red LED off
  digitalWrite(LED_GREEN, HIGH); // sets the green LED on
  tone(9,110, 100);
  delay(500); // waits half a second
  digitalWrite(LED_RED, HIGH); // sets the red LED on
  digitalWrite(LED_GREEN, LOW); // sets the green LED off
  tone(9,110, 100);
  delay(500); // waits half a second
  digitalWrite(LED_RED, LOW); // sets the red LED off
  digitalWrite(LED_GREEN, HIGH); // sets the green LED on
  tone(9,110, 100);
  delay(500); // waits half a second

  key = NO_KEY; // enter the while() loop, otherwise it'll skip. i could use do { } while();, but I'm lazy.
  {
    while (key == NO_KEY) {
      key = keypad.getKey();
      if (key == '#')
      {
        lcd.clear();
        lcd.print("Resetting:");
        lcd.setCursor(6,1);
        lcd.print("the Bomb!");
        delay(3000); //  3 sec delay
        void (*softReset) (void) = 0; //declare reset function @ address 0
        softReset();
        //timerSeconds = 300; // put 5 minutes on the clock
        // and we break the loop and go back to timer.
      }
      else  key = NO_KEY; // continue looking for pound key
    }
  }
}


smiley
« Last Edit: July 07, 2011, 08:42:24 am by soul1974 » Logged

illinois
Offline Offline
Newbie
*
Karma: 0
Posts: 19
helps im noobz
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey,
Just a quick note (I'm Chase one of the guys who programmed this apparent mess) to clear up some things.  Firstly I read the whole post and its good to see you guys helping out and fixing the code and its good to see something that I threw together in my basement see such interest.  Next I would like to apologize for the coding I didn't realize it was such a mess, I have done SOME coding before but very little I did most of the wiring and hardware stuff.  My friend Joey, who pretty well wrote the whole code, had never coded in the arduino format from what I know he has only programmed in C# so that might explain some of the weirdness of the code, that and it was done in a hurry.  Lastly i just wanted to say that i have tried to help the author of this post but he had a different hardware set up and also caught me in the middle of moving... just wanted to throw that in there because i do believe strongly in the importance of the arduino community and in helping out other diyers.  But yes thank you for your imputs and im going to forward this post to joey and have him read the comments and we will try to fix the code and learn thanks again!
-Chase
Logged

Pages: 1 2 [3]   Go Up
Jump to: