I'm a noob to the Arduino and if I posted in the wrong place I'm sorry. I started three weeks ago and bought the ELEGOO stater kit for mega 2560. I have done most of the project of the. I thought I could start my project that I wanted to do and that is why I bought the starter kit.
I want a programmable timer to heat treat firing pins for bolt action rifles.
I found a program that I thought would be easy enough to make a few modifications and I would be done. Not as easy as it sounds.
I think I only need three changes to this program.
-
Add two buttons, one to increase the time on timer, and the other is to decrease the time the timer and have it displayed on the LCD Screen. On the first time it runs it can say Heat treat done Timer=(variable) right now the time is an integer for 10 seconds but I figure out how to change the time or display the variable.
-
Add a button AKA "Cycle Start" to start the timer, and relay. I cant figure that out either.
-
After the timer is done I want the buzzer to go of a few seconds then be "ready for state" to change the time if needed and or "Cycle Start" to run the timer again. And have the LCD screen say Heat treat done Timer=(variable) until then.
//Arduino Self-Timer
//T.K.Hareendran
//www.electroschematics.com
#include <LiquidCrystal.h>
LiquidCrystal lcd(7,8,9,10,11,12);
int runTimer = 1;
int runFor = 10; // time in seconds
int buzzerPin = 13;
int relayPin=4;
int data = 0;
void setup() {
pinMode(buzzerPin, OUTPUT);
pinMode(relayPin,OUTPUT);
lcd.begin(16, 2);
}
void loop() {
if(runTimer == 1){
digitalWrite(relayPin,HIGH); // relay is OFF during countdown
/* *change to HIGH if you want the relay to be ON while countdowning /
lcd.clear();
lcd.print("TIMER=");
//Start timer
timer();
} else {
digitalWrite(relayPin,LOW); // relay is ON when time expired
/ *change to LOW if you want the relay to be OFF when the time expired */
}
runTimer = 0;
lcd.noDisplay();
delay(250);
for(int duration = 0; duration < 100; duration ++){
digitalWrite(buzzerPin, HIGH);
delayMicroseconds(500);
digitalWrite(buzzerPin, LOW);
delayMicroseconds(500);
}
lcd.display();
delay(250);
}
void timer() {
for(int timer = runFor;timer > 0; --timer){
if(timer >= 10) {
lcd.setCursor(6,0);
} else {
lcd.setCursor(6,0);
lcd.print("0");
lcd.setCursor(7,0);
}
lcd.print(timer);
lcd.print(" SECOND!");
delay(1000);
}
lcd.setCursor(0,0);
lcd.clear();
lcd.print(" HEAT TREAT DONE");
lcd.setCursor (0,1);
lcd.print("TIMER=");
lcd.print(" SECONDS");
}
heat_treat_version_15.ino (1.44 KB)