It's very nice. Thank u for it. But sir I need in thise little bit change.... I want when button released second will be zero but timer will start without button released.
This what exactly I was looking but instead of press button I want use digital read , like if the water level reached high the buzzer will on for 10 seconds plz tell me what changes I hv to do
@@automationhouse8613 but in your video when the switch button is pressed for a long time the led will light up and when released the timer will start counting again in other words the switch button functions as a reset button. But when i tried it, it didn't work. Please your solution
@@automationhouse8613 #include LiquidCrystal_I2C lcd(0x27, 20, 4); //SCL D1, SDA D2 int m0=0; //varialbe for indication of button pressed or not int delay_sec=05; // variable store OFF delay time unsigned long current_time=0; //variable that will store current value of millis()function unsigned long previous_time=0; // variable that will store previous value of millis() function int sec=0; //variable that will count seconds int current_state=0; //variable store current button State int previous_state=0; //variable store previous button State void setup() { //lcd.begin(16,2); pinMode(5,INPUT_PULLUP); //timer and output reset button pinMode(12,OUTPUT); lcd.begin(); lcd.backlight(); lcd.setCursor(0,0); lcd.print("SHOGUN PROJECT"); lcd.clear(); } void loop() { current_time=millis(); current_state=digitalRead(5); if (current_state!=previous_state) { if(current_state==LOW) {m0=0; digitalWrite(12,LOW); lcd.clear(); lcd.setCursor(0,0); lcd.print("BUTTON PRESSED"); lcd.setCursor(0,1); lcd.print("LIGHT ON"); } if(current_state==HIGH) {m0=1; sec=0; lcd.clear(); lcd.setCursor(0,0); lcd.print("BUTTON RELEASED"); //msg will print on display when button pressed } previous_state=current_state; } if(m0==1) { if((current_time-previous_time)>=1000) { sec++; lcd.clear(); lcd.setCursor(0,0); lcd.print("BUTTON RELEASED"); //msg will print on display when button released lcd.setCursor(0,1); lcd.print("DELAY SEC: ");//msg will print on display when button released lcd.print(sec);// Seconds value will print on display when button released previous_time=current_time; if (sec>=delay_sec) { m0=0; lcd.clear(); digitalWrite(12,HIGH); lcd.setCursor(0,0); lcd.print("DELAY COMPLETED");//msg will display at the end of delay lcd.setCursor(0,1); lcd.print("LIGHT OFF"); //msg will display at the end of delay delay(1000); //msg for ending delay time lcd.clear(); lcd.setCursor(0,0); lcd.print("TIMER STATUS:OFF"); //msg will display when timer off lcd.setCursor(0,1); lcd.print("SET DELAY: "); //msg will display when timer off lcd.print(delay_sec); //delay time in seconds will print on display when timer off } } } }
@@automationhouse8613 I don't use a switch/push button as an input, but make a connection from +5V pin to digital pin no. 5, does this have any effect?
اسلام علیکم محب الرحمان بھائی آپ کی ویڑیوز سے ہم نے بہت کچھ سیکھا - جزاک اللہ اس پرو جیکٹ کے بارے میں بات پوچھنی ہے کہ اگر سیکنڈ کاونٹ کے دوران بٹن پریس کرے تو ٹائمر ریسیٹ ہوگا یا چلتا رہے گا؟
Timer reset ho jay ga jb tak button on rhy ga light on rhy gi or timer b off hoga jasy hi button release hoga osky bad timer run hoga or time complete hony k bad light off kr dy ga
@@automationhouse8613 actually I am working on Bluetooth remote here where I have to give the command for bulb to become on but i need this bulb should off after 3 seconds, like for car porch No need to to make it off by pressing another button , Simply auto off bulb after Bluetooth on
Thank you 💐💐
It's very nice. Thank u for it.
But sir I need in thise little bit change....
I want when button released second will be zero but timer will start without button released.
Thanks for this important timer design.
This what exactly I was looking but instead of press button I want use digital read , like if the water level reached high the buzzer will on for 10 seconds plz tell me what changes I hv to do
@Automation House why when the switch is in the high position the timer keeps going on and off the LED? does the reset function not work?
Yes dear the rest of code will be stay in working seimulteneusly... program will not be stuck in timer code
@@automationhouse8613 but in your video when the switch button is pressed for a long time the led will light up and when released the timer will start counting again in other words the switch button functions as a reset button. But when i tried it, it didn't work. Please your solution
@@automationhouse8613
#include
LiquidCrystal_I2C lcd(0x27, 20, 4); //SCL D1, SDA D2
int m0=0; //varialbe for indication of button pressed or not
int delay_sec=05; // variable store OFF delay time
unsigned long current_time=0; //variable that will store current value of millis()function
unsigned long previous_time=0; // variable that will store previous value of millis() function
int sec=0; //variable that will count seconds
int current_state=0; //variable store current button State
int previous_state=0; //variable store previous button State
void setup() {
//lcd.begin(16,2);
pinMode(5,INPUT_PULLUP); //timer and output reset button
pinMode(12,OUTPUT);
lcd.begin();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("SHOGUN PROJECT");
lcd.clear();
}
void loop() {
current_time=millis();
current_state=digitalRead(5);
if (current_state!=previous_state)
{
if(current_state==LOW)
{m0=0;
digitalWrite(12,LOW);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("BUTTON PRESSED");
lcd.setCursor(0,1);
lcd.print("LIGHT ON");
}
if(current_state==HIGH)
{m0=1;
sec=0;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("BUTTON RELEASED"); //msg will print on display when button pressed
}
previous_state=current_state;
}
if(m0==1)
{
if((current_time-previous_time)>=1000)
{
sec++;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("BUTTON RELEASED"); //msg will print on display when button released
lcd.setCursor(0,1);
lcd.print("DELAY SEC: ");//msg will print on display when button released
lcd.print(sec);// Seconds value will print on display when button released
previous_time=current_time;
if (sec>=delay_sec)
{
m0=0;
lcd.clear();
digitalWrite(12,HIGH);
lcd.setCursor(0,0);
lcd.print("DELAY COMPLETED");//msg will display at the end of delay
lcd.setCursor(0,1);
lcd.print("LIGHT OFF"); //msg will display at the end of delay
delay(1000); //msg for ending delay time
lcd.clear();
lcd.setCursor(0,0);
lcd.print("TIMER STATUS:OFF"); //msg will display when timer off
lcd.setCursor(0,1);
lcd.print("SET DELAY: "); //msg will display when timer off
lcd.print(delay_sec); //delay time in seconds will print on display when timer off
}
}
}
}
@@automationhouse8613 Please check where the deficiencies are until the button switch cannot function to reset the timer and turning on LED
@@automationhouse8613 I don't use a switch/push button as an input, but make a connection from +5V pin to digital pin no. 5, does this have any effect?
اسلام علیکم
محب الرحمان بھائی آپ کی ویڑیوز سے ہم نے بہت کچھ سیکھا - جزاک اللہ
اس پرو جیکٹ کے بارے میں بات پوچھنی ہے کہ اگر سیکنڈ کاونٹ کے دوران بٹن پریس کرے تو ٹائمر ریسیٹ ہوگا یا چلتا رہے گا؟
Timer reset ho jay ga jb tak button on rhy ga light on rhy gi or timer b off hoga jasy hi button release hoga osky bad timer run hoga or time complete hony k bad light off kr dy ga
محب الرحمان بھائی بہت بہتر
اس پروجیکٹ میں میں کچھ ایڈیٹینگ کرنے کی کوشش کرتا ہو اگر آگے آپکی مدد درکار ہو تو میں آپ سے رابطہ کرتا ہو
آپکا بہت بہت شکرہ
@@automationhouse8613 how to start timer if sensors input keep high?
sir please give the 4 channel different delay timer set custom timing for Arduino uno r3
Sir below is my code for automatically water level indicator using ultrasonic sensor but I want to add buzzer if the water reaches full tank for 10 seconds then it the buzzer should stop
@PCRduino thanks sir for the reply that code i have tried sir the buzzer wont stop after ten seconds instead it continuous to beep here i have uploaded the code plz check it sir ..
..........................................
const int trigPin = 2;
const int echoPin = 3;
int ledA = 13;
int ledB = 12;
int ledC = 11;
int ledD = 10;
int ledE = 9;
int buzzer = 8;
int A = 20;
int B = 16;
int C = 12;
int D = 8;
int E = 5;
int max_distance = 200;
void setup() {
Serial.begin(9600);
pinMode (ledA, OUTPUT);
pinMode (ledB, OUTPUT);
pinMode (ledC, OUTPUT);
pinMode (ledD, OUTPUT);
pinMode (ledE, OUTPUT);
pinMode (buzzer, OUTPUT);
digitalWrite(ledA, LOW);
digitalWrite(ledB, LOW);
digitalWrite(ledC, LOW);
digitalWrite(ledD, LOW);
digitalWrite(ledE, LOW);
digitalWrite(buzzer, LOW);
}
void loop() {
long duration, inches, cm;
pinMode(trigPin, OUTPUT);
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
pinMode(echoPin, INPUT);
duration = pulseIn(echoPin, HIGH);
cm = ( duration / 29 ) / 2;
inches = cm * 0.393701;
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
if (inches < max_distance) {
Serial.print(inches);
Serial.print("in");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(100);
digitalWrite (ledA, HIGH);
}
if (inches >= A) {
digitalWrite (ledA, HIGH);
digitalWrite (ledB, LOW);
digitalWrite (ledC, LOW);
digitalWrite (ledD, LOW);
digitalWrite (ledE, LOW);
}
else if (inches >= B) {
digitalWrite (ledA, LOW);
digitalWrite (ledB, HIGH);
digitalWrite (ledC, LOW);
digitalWrite (ledD, LOW);
digitalWrite (ledE, LOW);
}
else if (inches >= C) {
digitalWrite (ledA, LOW);
digitalWrite (ledB, LOW);
digitalWrite (ledC, HIGH);
digitalWrite (ledD, LOW);
digitalWrite (ledE, LOW);
}
else if (inches >= D) {
digitalWrite (ledA, LOW);
digitalWrite (ledB, LOW);
digitalWrite (ledC, LOW);
digitalWrite (ledD, HIGH);
digitalWrite (ledE, LOW);
}
else if (inches >= E) {
digitalWrite (ledA, LOW);
digitalWrite (ledB, LOW);
digitalWrite (ledC, LOW);
digitalWrite (ledD, LOW);
digitalWrite (ledE, HIGH);
}
else {
digitalWrite (ledA, HIGH);
digitalWrite (ledB, HIGH);
digitalWrite (ledC, HIGH);
digitalWrite (ledD, HIGH);
digitalWrite (ledE, HIGH);
}
}
long microsecondsToInches(long microseconds) {
return (microseconds / 74) / 2;
}
long microsecondsToCentimeters(long microseconds) {
return (microseconds / 29) / 2;
}
Hi dear what will the code if button is pressed or high and LED will be high again this LED will off while switch is on ,
Just read the status of led through digitalRead command and change the state at rising edge while pressing the input...
@@automationhouse8613 actually I am working on Bluetooth remote here where I have to give the command for bulb to become on but i need this bulb should off after 3 seconds, like for car porch
No need to to make it off by pressing another button ,
Simply auto off bulb after Bluetooth on
@@ObaidullahKakar then u should use timer to make it auto off after 3sec
@@automationhouse8613 why when the switch is in the high position the timer keeps going on and off the LED? does the reset function not work?