Go Down

Topic: Count Down Timer (Read 11 times) previous topic - next topic

new guy

hi, im looking to create a timer with the Arduino. my goal is to have a visual count down timer using an LCD(mine is a 16 pin lcd from lumix model S01602)
or 7seg leds. it should be accurate to 1/10 of a second and show MM,SS,TT.
when the timer reaches ZERO i want a relay to trigger either a light, an air blast or some kind of noise, i prefer a combination.  
this is for a prop bomb in live action war games that teams have to defuse either via cutting wires, a code entered, or a key.

anyone who can help me with the countdown and relay would be awesomely amazing. :)

Groove

Quote
that teams have to defuse either via cutting wires, a code entered, or a key


or a disrupter...  ;D
Per Arduino ad Astra

Mike Murdock

New Guy,

An Arduino such as the Duemilanove is easily capable of doing what you want.  All it will take is a little software :)

I would recommend that you work on this one piece at a time.  First, get a program to talk to your LCD, then add a timer to it, then add wire sensing to it, then add the sound effects.

If you want to use an external relay, you'll probably need to add a simple transistor circuit.  Have a look around this site, or use Google (try searching for Arduino transistor).

I like your idea about cutting a wire to stop the timer.  Set up a pin as an input with the pulldown resistor enabled.  Use the wire to connect +5V to the input pin.  The pin will read as '1' until the wire is cut, when it will start reading as a '0'.  You can also add more wires, each with their own input pin, in the same fashion.  If you cut the "wrong" wire, make your device explode immediately.

For a key, buy an inexpensive key switch, and wire it the same way as the "cut" wires.  When the key switch is on, the input will read '1', when off, '0'.

Regards,

-Mike

pwillard


new guy

i was hoping it was capable but wasn't sure about the output limitations on the Arduino. i think that might be the best way to go is one thing at a time. i was actually looking to find a countdown timer/relay online someplace but i couldn't find anything quite right.
im actually working on different relay transistor circuits now, problem is i don't know what kind of base current i will have, so i don't know what kind of transistor to use. the key i think i might have figured out, i need a three position two pole key switch. with power to the timer running though it. when the key is inserted and turned, it cuts power to everything, but turns power on to a buzzer or some lighting i have running through the case that signifies its disarming. its simple with no programing, just switches lol.  the post from pwillard is amazing, thats pretty much what im looking for, i guess i have to figure out what he did and try to use it to my advantage. thanks you guys. :)

new guy

ok, so i finally got my LCD talking to the Arduino, i used the hello world set up in the Tut part of Arduino (http://arduino.cc/en/Tutorial/LiquidCrystal) i know how to change the text in the programing, but i don't know how to interface my 4 buttons to the LCD. i did a tutorial where an led would turn off when the button was pushed, so i kind of get the button hook up aspect but not the LCD/button interface. any tips on that?

also, i cant figure out for the life of me how to get the timer code right. a friend of mine wrote this bit of code for me, but its not arduino friendly.

#include <LiquidCrystal.h>

int min=0;
int hour=0;
int sec=0;
string set=null

cin >> set;
while(set!="Q")
{
 if(set=="H")
 {
 hour=hour++;
 if(hour>12)
 {
   hour=1;
 }
}
else if(set=="M")
{min=min++;
if(min>60)
{
 min=0;
 hour=hour++;
 if(hour>12)
 {
   hour=1;
   
   
 }
 else if(set=="s")
 {
   sec=sec++;
   if (sec>60)
   {
     hour=hour++;
     if(hour>12)
     {
       hour=1;
     }
     min=0;
   }
 }
}
countdown(min,hour,sec)
{
 while(min!=0&&sec!=0&&hour!=0)
 {
   delay 1000ms;
   sec=sec--;
   if(sec>1)
   {
     min=min--;
     if(min>1&&hour!=0)
     {
       min=59;
       hour=hour--;
       if (hour!=0&&min!=0)
       {
         sec=60;
       }
     }
   }
 }
if(min==0&&sec--0&&hour==0)
{
 this is where the event code should be, ie trigger a relay, buzzer or lights speaking of buzzer, i used the melody tutorial to get my little buzzer singing to me.


im not sure what the string set null is(cause it doesnt work with the arduino) all of this was written with keyboards and computers in mind

even if i could get the timer to count down on the LCD i still need button comtroles, one for mins secs and hours and a go button :exclamation :-?

also, i tried to compile the bit of code from here ( http://pastebin.com/f57045830 ) but i keep getting errors. part of it i believe is cause i don't have the keypad library and don't know where to get any other libraries either.

AlphaBeta

#6
Jul 12, 2009, 12:57 pm Last Edit: Jul 12, 2009, 07:20 pm by AlphaBeta Reason: 1
Humble suggestion:
Keypad library for handling the keypad
LED library for handling the LEDs
Summer library for handling the piezo summer

I think you should use a finite state machine for implementing this bomb.
Fictional states:

  • Standby
  • Arm
  • Countdown
  • Disarm
  • Explode

http://www.arduino.cc/playground/Code/FiniteStateMachine library for handling the architectural design of the system.
http://www.arduino.cc/playground/Code/TimedAction library for any recurring events that need to constantly happen. [blinking leds, emitting beeps etc etc]
http://www.arduino.cc/playground/Code/EventFuse library for handling the countdown mechanism.
[edit]If you want to have a password, you might find this useful: http://www.arduino.cc/playground/Code/Password :)[/edit]

new guy

thanks alpha beta, i will check this out and see if i can figure out how to get them to work together with an lcd. its the interface stuff that gets me confused more then anything. if i see code i can usually read it and guess what its doing, but coming up with it myself is damn near imposable.
you know there use to be a time when i could find just about anything on the internet, i couldn't find any of the libraries anyplace. thanks fo the links :-)

im over my head

im having the same trouble, i don't know much about code but im stuck in a situation of "do this or your fired" lol. im trying to create an LCD stop watch using 4 buttons. i can get my LCD working via the hello world stuff, an i can make my buttons work with the led stuff. i just cant put two and two together to get one, one complete project that is if anyone knows a good button/lcd interaction Tut, please let me know

Go Up