Countdown timer

Hello People, i know i’ve been a very inactive member of this community, but i remain an arduino fan, mostly because of work, i’ve been really busy with projects, learning how to use industrial PLC’s and its applications, anyways, so at work, i got involved in a little project, is a heatshrink device, all it does it heats up a metal fixture to a certain temperature, and you place a “splice protector” is a plastic transparent case to protect fiber optic, so far i have pretty much all covered, im using a PID controller and a solid state relay to regulate temperature, except the time the “splice protector” needs to be inside the fixture, all i need is set a timer for about a minute, so i was thinking of using 2 buttons, a buzzer, and an arduino micro, i already convinced my boss to get the arduinos, lol, i want to use one button to star a countdown or count up to 60 seconds, then once it reaches 60, or 0 if countdown, to pulse the buzzer so the operator knows the “splice protector” is ready, and then push another button to reset the count, i am pretty amateur with code, even “primitive” if you’d like, so i wanted to ask for some guidance regarding the code, how can i make a count from 60 to 0 or viceversa? can i activate some kind of shift registers? or read a pwm? any help is appreciated :slight_smile: thanks!

this is what the little box for the heatshrink device looks like:

Assembly.PDF (289 KB)

int START = 5; int RESETHI = 7; int RESETIN = 6; int BUZZER = 9; int val =0; int val2 = 0; void setup () { pinMode(START, INPUT); pinMode(RESETHI, OUTPUT); pinMode(BUZZER, OUTPUT); pinMode(RESETIN, INPUT); }

void loop ()

{ digitalWrite (RESETHI, HIGH);

val = digitalRead (START); delay(5000); digitalWrite (BUZZER, val);

val2 = digitalRead (RESETIN); digitalWrite (BUZZER, LOW);

}

Not really working, any suggestions?

Holy run-on-sentences batman.

Use code tags

Also, check the millis() function. It will give the 'current time' (Since boot) in milliseconds.

BlueLoneWolf: Not really working, any suggestions?

NE555

updated code:

int START = 5; //read in pushbutton, other end of pushbutton connected to 5v int RESETHI = 7; // voltage out for reset button pushbutton int RESET = 6; // pin 6 reads value of reset pushbutton (high or low) int BUZZER = 9; //buzzer connected to pin 9 and ground int val = 0; // value stored for start button state int val2 = 0; // value stored for reset button state void setup () { pinMode(START, INPUT); pinMode(RESETHI, OUTPUT); pinMode(BUZZER, OUTPUT); pinMode(RESET, INPUT); }

void loop ()

{ digitalWrite (RESETHI, HIGH); //arms reset push button

val = digitalRead(START); //reads pin 5 value high or low if (val, HIGH); { delay(1000); digitalWrite (BUZZER, HIGH); } val2 = digitalRead(RESET); //reads reset button state if (val2, HIGH); //if it is high at pin 6: {digitalWrite(BUZZER, LOW);} // it turns off buzzer

}

i dont know what im doing wrong, the delay format shouldnt matter right?

Paul__B:

BlueLoneWolf: Not really working, any suggestions?

NE555

well, is not really going to work for me, since is a heater im trying to time and this thing reaches temps of 320 celcius, and 555 is known to drift over temperature, so it wont really work for me since the time the splice protector stays under heat is critical

1) Use Code tags 2) If() statements don't get semi-colons unless you want them to end immediately. Also they don't use commas: http://arduino.cc/en/Reference/HomePage#.Uytt1oWx7gk 3) I don't see how an NE555 vs arduino would matter based on temperature. Both will drift with temperature and we are all assuming you are not mounting it anywhere near the 320C area. Otherwise you'll fry your various parts. 4) Use code tags.

OK, i got it to work!!! updated code:

int STARTBUTTON =    4;      //read in pushbutton, other end of pushbutton connected to 5v
 int RESETHI =  2;            // voltage out for reset button   pushbutton

int STARTBUTTONSTATE = 0;     //VALUE TO STORE START BUTTON HIGH OR LOW
int RESETBUTTONSTATE = 0;     // VALUE TO STORE RESET BUTTON HIGH OR LOW
int RESET =    3;             //   reset pushbutton (high or low)
int BUZZER =   6;             //   buzzer connected to pin 6 and ground

void setup ()
{
pinMode(STARTBUTTON, INPUT);      
pinMode(RESETHI, OUTPUT);   
pinMode(BUZZER, OUTPUT);    
pinMode(RESET, INPUT); 
Serial.begin(9600);
}

      void loop ()

{ 
       STARTBUTTONSTATE = digitalRead(STARTBUTTON);   //READS PUSHBUTTON "STARTBUTTON"
       RESETBUTTONSTATE = digitalRead(RESET);         //READS PUSHBUTTON "RESET"
       
        digitalWrite (RESETHI, HIGH);                 //arms reset push button
        
        if (STARTBUTTONSTATE== HIGH)                  //IF START PUSHBUTTON IS HIGH IT WAITS "X" SECONDS AND WRITES "HIGH TO THE BUZZER
        {
          delay(60000);
         digitalWrite(BUZZER, HIGH);
         }
       
        if (RESETBUTTONSTATE==HIGH)                   //IF RESET PUSHBUTTON GOES HIGH, IT SENDS THE BUZZER TO LOW STATE
        {digitalWrite (BUZZER, LOW);}
                                  

   
}

it works really smooth, now, i need to figure out how to connect an LCD display to it, and display the time and be able to change the delay time with pushbuttons, so the operator can change the amount of time before the buzzer goes off

Well, you are enjoying yourself - and learning. That's the important thing. :D

thank you, so i’ve been wanting to add some stuff to the code, i need to add a feature that reads the reset button so it stops the buzzer from going off “before it does if the start button was already pressed” because right now the “RESET” button only turns off the “buzzer” if the buzzer is already on, in simple words, it should be able to do this:

Button A—> ON ---- > WAIT TIME----> BUZZER ON
—>OFF----->NOTHING

BUTTON B—>ON ----->BUZZER OFF
—>ON AT ANY POINT DURING “WAIT TIME” OF BUTTON A ------> BUZZER OFF

I read in a post in the forums that this can be done by doing something like this?
“if ( (val == val2) && (val != buttonstate) ) {”

any suggestions?

question, how can i change the value of the "delay"?? by reading the pushbuttons? but first, how can i even assign a variable or value that can control the value of the "delay"? would something like this makes sense?:

int DELAY = 0;

DELAY = delay();

ok, so the biggest challenge seems to be to use the "DELAY" value, as an actual "delay()" parameter, i can't find anything related, im stuck, any way to use a value stored on a variable as an actual "delay()" parameter???