Indeed I found something which might help you:
It comes with all components which are used in the sketch.
Indeed I found something which might help you:
It comes with all components which are used in the sketch.
rpt007:
I see, you modified your reply already while I was writing my last reply.Ok, I give up and post your working code, but after that I think I will be out here.
The following code is close to what I think you want to have.Your turn is to adjust it to your needs.
As stated before it will be very readable, but a professional programmer will see a lot of improvement potential due to a lot of similar sketch parts.Here it is:
// definitions
#define LED1 9
#define LED3 8
#define LED4 7
#define LED2 6
#define LED5 5
#define BTN_PIN 4
// libraries
// #include "Wire.h"
#include <LiquidCrystal.h>
// variables
int delay1 = 1000;
int delay2 = 2000;
int delay3 = 3000;
int delay5 = 5000;
int delay10 = 10000;
int delay20 = 20000;
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 10, 4, 3, 2);
void setup()
{
// LCD setup
lcd.begin(16, 2);
// initialize outputs
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);
// initialize BTN_PIN as input with pullup resistor
pinMode(BTN_PIN, INPUT_PULLUP);
// Welcome Screen
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Welcome to LED");
lcd.setCursor(0, 1);
lcd.print(" Status Sketch");
delay(delay3);
// Start Screen
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Start => Press");
lcd.setCursor(0, 1);
lcd.print("Button and Hold");
delay(delay3);
}
void loop()
{
while (digitalRead(BTN_PIN) == LOW) // Will be executed while button on pin 4 is pressed and therefore pin 4 is connected to GND
{
lcd.clear();
digitalWrite(LED1, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED1 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime= 2sec");
delay(delay1); // wait for a second
digitalWrite(LED2, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED2 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 3sec");
delay(delay3); // wait for 3 seconds
digitalWrite(LED3, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED3 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
digitalWrite(LED4, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED4 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 5sec");
delay(delay5); // wait for 5 seconds
digitalWrite(LED2, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED2 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 2sec");
delay(delay2); // wait for 2 seconds
digitalWrite(LED1, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED1 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
digitalWrite(LED5, HIGH);
lcd.setCursor(0, 0);
lcd.print("LED5 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 3sec");
delay(delay3);
digitalWrite(LED2, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED2 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second delay(1000);
digitalWrite(LED2, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED2 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime =2sec");
delay(delay2); // wait for 2 seconds
//digitalWrite(LED5, LOW); // turn the LED off by making the voltage LOW
delay(delay1); // wait for a second
digitalWrite(LED2, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED2 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
digitalWrite(LED4, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED4 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
digitalWrite(LED3, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED3 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 2sec");
delay(delay2); // wait for 2 seconds
digitalWrite(LED2, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED2 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Full Cycle");
lcd.setCursor (0, 1);
lcd.print("was completed");
delay(delay3);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Next Cycle");
lcd.setCursor (0, 1);
lcd.print("Start in 3sec");
}
//Any Other Task here
delay(delay3);
}
Bro!- This code starts without pressing the button, when i conect to power suply 5v(
and after completion of the cycle automatically restarts jobs...I would like so that the process began when I click on the button and when will the whole process is not repeated without pressing the button, until I push on the button... " Full Cycle was completed " - This message should remain on the screen before pressing the start button... thanks in advance!!!
rpt007:
Sure, you have to
- define the emergency button (e.g. wired to A1)
- set pinMode same way as for the other button (BTN_PIN)
- include a digitalRead for this emergency button in the loop() after each section (section=one action for a LED) in the while loop
- when a LOW is detected for the emergency button, execute a function, e.g. call it "emergencyBreak()"
- at the very end of your whole sketch (outside of the loop() brackets) insert the code for the new function like this:
void emergencyBreak() {
lcd.clear();
digitalWrite(LED1, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(LED2, HIGH);
digitalWrite(LED3, HIGH);
digitalWrite(LED4, HIGH);
digitalWrite(LED5, HIGH);
lcd.setCursor(0, 0);
lcd.print(" ALARM! ");
lcd.setCursor (0, 1);
lcd.print("Emergency Break!");
delay(delay10); // wait for 10 seconds
}
PLS I attached to this code, too, but this button specifiable pin-0 and if possible, the button on pin-4 move to pin-1
Sorry, but now it is your turn to go on.
I did more than it is usual in this forum.
But - this forum is meant to help you to learn how to fish, not catching all fish for you.
I said earlier there are some little mistakes/errors in the sketch.
Pls find out on your own - only this gives you the learning effect.
And: in my environment it doesn't start on its own. I have to press the button for about 2-3 seconds before the cycle starts.
This is definitely my last post in this thread if you don't come back with own proposals.
rpt007:
Sorry, but now it is your turn to go on.
I did more than it is usual in this forum.But - this forum is meant to help you to learn how to fish, not catching all fish for you.
I said earlier there are some little mistakes/errors in the sketch.
Pls find out on your own - only this gives you the learning effect.And: in my environment it doesn't start on its own. I have to press the button for about 2-3 seconds before the cycle starts.
This is definitely my last post in this thread if you don't come back with own proposals.
it's kind so it turns out that in the depths of the sea to throw the man who does not know how to swim,
if he did not help who threw it.... PLS... help me!!!...
rpt007:
Sorry, but now it is your turn to go on.
I did more than it is usual in this forum.But - this forum is meant to help you to learn how to fish, not catching all fish for you.
I said earlier there are some little mistakes/errors in the sketch.
Pls find out on your own - only this gives you the learning effect.And: in my environment it doesn't start on its own. I have to press the button for about 2-3 seconds before the cycle starts.
This is definitely my last post in this thread if you don't come back with own proposals.
// definitions
#define LED1 9
#define LED3 8
#define LED4 7
#define LED2 6
#define LED5 5
#define LED6 A0
#define BTN_PIN 1
// libraries
// #include "Wire.h"
#include <LiquidCrystal.h>
// variables
int delay1 = 1000;
int delay2 = 2000;
int delay3 = 3000;
int delay5 = 5000;
int delay10 = 10000;
int delay20 = 20000;
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 10, 4, 3, 2);
void setup()
{
// LCD setup
lcd.begin(16, 2);
// initialize outputs
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);
pinMode(LED6, OUTPUT);
// initialize BTN_PIN as input with pullup resistor
pinMode(BTN_PIN, INPUT_PULLUP);
// Welcome Screen
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Welcome to LED");
lcd.setCursor(0, 1);
lcd.print(" Status Sketch");
delay(delay3);
// Start Screen
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Start => Press");
lcd.setCursor(0, 1);
lcd.print("Button and Hold");
delay(delay3);
lcd.clear();
digitalWrite(LED6, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print(" S T A R T ");
lcd.setCursor (0, 1);
lcd.print("I a m R E A D Y !");
delay(delay1);
}
void loop()
{
while (digitalRead(BTN_PIN) == LOW) // Will be executed while button on pin 1 is pressed and therefore pin 1 is connected to GND
{
lcd.clear();
digitalWrite(LED1, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED1 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime= 2sec");
delay(delay1); // wait for a second
digitalWrite(LED2, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED2 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 3sec");
delay(delay3); // wait for 3 seconds
digitalWrite(LED3, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED3 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
digitalWrite(LED4, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED4 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 5sec");
delay(delay5); // wait for 5 seconds
digitalWrite(LED2, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED2 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 2sec");
delay(delay2); // wait for 2 seconds
digitalWrite(LED1, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED1 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
digitalWrite(LED5, HIGH);
lcd.setCursor(0, 0);
lcd.print("LED5 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 3sec");
delay(delay3);
digitalWrite(LED2, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED2 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second delay(1000);
digitalWrite(LED2, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED2 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime =2sec");
delay(delay2); // wait for 2 seconds
//digitalWrite(LED5, LOW); // turn the LED off by making the voltage LOW
delay(delay1); // wait for a second
digitalWrite(LED2, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED2 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
digitalWrite(LED4, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED4 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
digitalWrite(LED3, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED3 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 2sec");
delay(delay2); // wait for 2 seconds
digitalWrite(LED2, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED2 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Full Cycle");
lcd.setCursor (0, 1);
lcd.print("was completed");
delay(delay3);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Next Cycle start");
lcd.setCursor (0, 1);
lcd.print("whan push on BTN");
digitalWrite(LED5, LOW);
digitalWrite(LED6, LOW);
}
//Any Other Task here
delay(delay3);
}
So I rewrote something but could not add the code[ emergencyBreak ]* to the pin-0
You modified just two text outputs.
That has almost nothing to do how to learn Arduino language.
I will give some hints:
That said, you will have to learn
So you see, you will have to learn a lot more than just exchanging text strings in a lcd.print command.
rpt007:
You modified just two text outputs.
That has almost nothing to do how to learn Arduino language.I will give some hints:
- I didn't talk about Pin 0, but of A0, which is an analogue pin
- If you want to include the emergency function, you have to combine it with your current code (learn how to use functions)
- You have to define the emergency button as I said earlier
- You need a digitalread of the emergency button pretty often within the main loop
- Due to all the delays in the main loop you won't realize immediate actions on pressing the emergency button
- If you want to avoid, that the cycle automatically repeats over and over again, you need a state variable which stores a "1" or "0" (or "false" / "true, using a boolean) and will be reset whenever you have a state change
That said, you will have to learn
- how to deal with functions
- how to replace delay() with millis() -> have a look at the Arduino example "Blink without delay"
- how to deal with state machines
So you see, you will have to learn a lot more than just exchanging text strings in a lcd.print command.
// definitions
#define LED1 9
#define LED3 8
#define LED4 7
#define LED2 6
#define LED5 5
#define LED6 A0
#define BTN_PIN 1
// libraries
// #include "Wire.h"
#include <LiquidCrystal.h>
// variables
int delay1 = 1000;
int delay2 = 2000;
int delay3 = 3000;
int delay5 = 5000;
int delay10 = 10000;
int delay19 = 19000;
int delay20 = 20000;
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 10, 4, 3, 2);
void setup()
{
// LCD setup
lcd.begin(16, 2);
// initialize outputs
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);
pinMode(LED6, OUTPUT);
// initialize BTN_PIN as input with pullup resistor
pinMode(BTN_PIN, INPUT_PULLUP);
// Welcome Screen
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Welcome to");
lcd.setCursor(0, 1);
lcd.print(" G E O R G I A ");
delay(delay3);
// Start Screen
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Start => Press");
lcd.setCursor(0, 1);
lcd.print("Button and Hold");
delay(delay3);
lcd.clear();
digitalWrite(LED6, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print(" S T A R T ");
lcd.setCursor (0, 1);
lcd.print("I a m R E A D Y !");
delay(delay1);
}
void loop()
{
while (digitalRead(BTN_PIN) == LOW) // Will be executed while button on pin 1 is pressed and therefore pin 1 is connected to GND
{
lcd.clear();
digitalWrite(LED1, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED1 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime= 2sec");
delay(delay1); // wait for a second
digitalWrite(LED2, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED2 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 3sec");
delay(delay3); // wait for 3 seconds
digitalWrite(LED3, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED3 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
digitalWrite(LED4, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED4 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 5sec");
delay(delay5); // wait for 5 seconds
digitalWrite(LED2, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED2 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 2sec");
delay(delay2); // wait for 2 seconds
digitalWrite(LED1, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED1 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
digitalWrite(LED5, HIGH);
lcd.setCursor(0, 0);
lcd.print("LED5 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 3sec");
delay(delay2);
digitalWrite(LED2, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED2 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 20sec");
delay(delay20); // wait for a second delay(1000);
digitalWrite(LED2, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED2 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime =2sec");
delay(delay2); // wait for 2 seconds
//digitalWrite(LED5, LOW); // turn the LED off by making the voltage LOW
digitalWrite(LED5, LOW); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED5 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
digitalWrite(LED2, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED2 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 20sec");
delay(delay20); // wait for a second delay(1000);
digitalWrite(LED4, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED4 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
digitalWrite(LED3, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED3 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 2sec");
delay(delay2); // wait for 2 seconds
digitalWrite(LED2, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED2 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime =2sec");
delay(delay2); // wait for 2 seconds
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Full Cycle");
lcd.setCursor (0, 1);
lcd.print("was completed");
delay(delay3);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Next Cycle start");
lcd.setCursor (0, 1);
lcd.print("whan push on BTN");
digitalWrite(LED5, LOW);
digitalWrite(LED6, LOW);
}
//Any Other Task here
delay(delay3);
}
so, there is my full modification, what i want really, there was modified the time Sequence... but i can not to paste there " emergency brake "
// definitions
#define LED1 9
#define LED3 8
#define LED4 7
#define LED2 6
#define LED5 5
#define LED6 A0
#define BTN1 1
#define BTN2 0
// libraries
// #include "Wire.h"
#include <LiquidCrystal.h>
// variables
int delay1 = 1000;
int delay2 = 2000;
int delay3 = 3000;
int delay5 = 5000;
int delay10 = 10000;
int delay19 = 19000;
int delay20 = 20000;
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 10, 4, 3, 2);
void setup()
{
// LCD setup
lcd.begin(16, 2);
// initialize outputs
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);
pinMode(LED6, OUTPUT);
// initialize BTN_PIN as input with pullup resistor
pinMode(BTN1, INPUT_PULLUP);
pinMode(BTN2, INPUT_PULLUP);
// Welcome Screen
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Welcome to");
lcd.setCursor(0, 1);
lcd.print(" G E O R G I A ");
delay(delay3);
// Start Screen
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" MARGALEFI ");
lcd.setCursor(0, 1);
lcd.print(" JIMALEFI ");
delay(delay3);
lcd.clear();
digitalWrite(LED6, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print(" S T A R T ");
lcd.setCursor (0, 1);
lcd.print("MZAD YOFNA !");
delay(delay1);
}
void loop()
{
while (digitalRead(BTN1) == LOW) // Will be executed while button on pin 1 is pressed and therefore pin 1 is connected to GND
{
lcd.clear();
digitalWrite(LED1, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED1 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime= 2sec");
delay(delay1); // wait for a second
digitalWrite(LED2, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED2 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 3sec");
delay(delay3); // wait for 3 seconds
digitalWrite(LED3, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED3 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
digitalWrite(LED4, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED4 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 5sec");
delay(delay5); // wait for 5 seconds
digitalWrite(LED2, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED2 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 2sec");
delay(delay2); // wait for 2 seconds
digitalWrite(LED1, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED1 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
digitalWrite(LED5, HIGH);
lcd.setCursor(0, 0);
lcd.print("LED5 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 3sec");
delay(delay2);
digitalWrite(LED2, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED2 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 20sec");
delay(delay20); // wait for a second delay(1000);
digitalWrite(LED2, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED2 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime =2sec");
delay(delay2); // wait for 2 seconds
//digitalWrite(LED5, LOW); // turn the LED off by making the voltage LOW
digitalWrite(LED5, LOW); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED5 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
digitalWrite(LED2, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED2 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 20sec");
delay(delay20); // wait for a second delay(1000);
digitalWrite(LED4, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED4 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
digitalWrite(LED3, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED3 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 2sec");
delay(delay2); // wait for 2 seconds
digitalWrite(LED2, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED2 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime =2sec");
delay(delay2); // wait for 2 seconds
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("VEMKIJINA UKAXLE");
lcd.setCursor (0, 1);
lcd.print("was completed");
delay(delay3);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" gamoushvi ");
lcd.setCursor (0, 1);
lcd.print(" shemdegi ");
digitalWrite(LED5, LOW);
digitalWrite(LED6, LOW);
}
//Any Other Task here
delay(delay3);
}
void emergencyBreak() {
while (digitalRead(BTN2) == LOW) // Will be executed while button on pin 1 is pressed and therefore pin 1 is connected to GND
lcd.clear();
digitalWrite(LED1, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(LED2, HIGH);
digitalWrite(LED3, HIGH);
digitalWrite(LED4, HIGH);
digitalWrite(LED5, HIGH);
lcd.setCursor(0, 0);
lcd.print(" ALARM! ");
lcd.setCursor (0, 1);
lcd.print("Emergency Break!");
delay(delay10); // wait for 10 seconds
}
there is not warking emergency break
Certainly, this can't work:
you should not use pins 0 and 1 as those are for the serial communication
-> use A1 and A2
Your sketch runs through the whole loop when the while condition was fulfilled by pressing BTN1
It will never come to the emergencyBreak() function as the function is never called WITHIN MAIN loop()
-> as I adviced earlier: you have to read BTN2 as often as you can in the main loop and NOT within the function itself!
-> as long as your sketch is full of delays, the only chance is, to read BTN2 after each section (I define section here in your sketch as one block where one action was done with one LED
-> include
if (digitalRead(BTN2) == LOW)
{
emergencyBreak();
}
AND delete the first line within the emergencyBreak function.
Pls do me the favor and learn, what I told you to learn. I am losing patience, as this code won't be a good example on the long run, as long as you don't listen and deal with getting rid of all the delays -> you will see, that it won't be very responsive at all, due to the delays in the main loop.
So you will always have to wait at least as long as a block has been finished until the Arduino comes to the point to read BTN2.
While you are on that level I don't dare to propose going with interrupts ...
I will assist you further when I see, you have tried to understand and implemented at least some of my previous comments and suggestions.
rpt007:
Certainly, this can't work:
you should not use pins 0 and 1 as those are for the serial communication
-> use A1 and A2Your sketch runs through the whole loop when the while condition was fulfilled by pressing BTN1
It will never come to the emergencyBreak() function as the function is never called WITHIN MAIN loop()
-> as I adviced earlier: you have to read BTN2 as often as you can in the main loop and NOT within the function itself!
-> as long as your sketch is full of delays, the only chance is, to read BTN2 after each section (I define section here in your sketch as one block where one action was done with one LED
-> includeif (digitalRead(BTN2) == LOW)
{
emergencyBreak();
}
AND delete the first line within the emergencyBreak function. Pls do me the favor and learn, what I told you to learn. I am losing patience, as this code won't be a good example on the long run, as long as you don't listen and deal with getting rid of all the delays -> you will see, that it won't be very responsive at all, due to the delays in the main loop. So you will always have to wait at least as long as a block has been finished until the Arduino comes to the point to read BTN2. While you are on that level I don't dare to propose going with interrupts ... I will assist you further when I see, you have tried to understand and implemented at least some of my previous comments and suggestions.
// definitions
#define LED1 9
#define LED3 8
#define LED4 7
#define LED2 6
#define LED5 5
#define LED6 A0
#define BTN1 A1
#define BTN2 A2
// libraries
// #include "Wire.h"
#include <LiquidCrystal.h>
// variables
int delay1 = 1000;
int delay2 = 2000;
int delay3 = 3000;
int delay5 = 5000;
int delay10 = 10000;
int delay19 = 19000;
int delay20 = 20000;
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 10, 4, 3, 2);
void setup()
{
// LCD setup
lcd.begin(16, 2);
// initialize outputs
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);
pinMode(LED6, OUTPUT);
// initialize BTN_PIN as input with pullup resistor
pinMode(BTN1, INPUT_PULLUP);
pinMode(BTN2, INPUT_PULLUP);
// Welcome Screen
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Welcome to");
lcd.setCursor(0, 1);
lcd.print(" G E O R G I A ");
delay(delay3);
// Start Screen
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" MARGALEFI ");
lcd.setCursor(0, 1);
lcd.print(" JIMALEFI ");
delay(delay3);
lcd.clear();
digitalWrite(LED6, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print(" S T A R T ");
lcd.setCursor (0, 1);
lcd.print("MZAD YOFNA !");
delay(delay1);
}
void loop()
{
while (digitalRead(BTN1) == LOW) // Will be executed while button on pin 1 is pressed and therefore pin 1 is connected to GND
{
lcd.clear();
digitalWrite(LED1, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED1 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime= 2sec");
delay(delay1); // wait for a second
if (digitalRead(BTN2) == LOW)
digitalWrite(LED2, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED2 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 3sec");
delay(delay3); // wait for 3 seconds
if (digitalRead(BTN2) == LOW)
digitalWrite(LED3, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED3 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
if (digitalRead(BTN2) == LOW)
digitalWrite(LED4, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED4 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 5sec");
delay(delay5); // wait for 5 seconds
if (digitalRead(BTN2) == LOW)
digitalWrite(LED2, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED2 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 2sec");
delay(delay2); // wait for 2 seconds
if (digitalRead(BTN2) == LOW)
digitalWrite(LED1, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED1 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
if (digitalRead(BTN2) == LOW)
digitalWrite(LED5, HIGH);
lcd.setCursor(0, 0);
lcd.print("LED5 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 3sec");
delay(delay2);
if (digitalRead(BTN2) == LOW)
digitalWrite(LED2, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED2 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 20sec");
delay(delay20); // wait for a second delay(1000);
if (digitalRead(BTN2) == LOW)
digitalWrite(LED2, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED2 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime =2sec");
delay(delay2); // wait for 2 seconds
//digitalWrite(LED5, LOW); // turn the LED off by making the voltage LOW
digitalWrite(LED5, LOW); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED5 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
if (digitalRead(BTN2) == LOW)
digitalWrite(LED2, HIGH); // turn the LED on (HIGH is the voltage level)
lcd.setCursor(0, 0);
lcd.print("LED2 = ON");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 20sec");
delay(delay20); // wait for a second delay(1000);
if (digitalRead(BTN2) == LOW)
digitalWrite(LED4, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED4 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 1sec");
delay(delay1); // wait for a second
if (digitalRead(BTN2) == LOW)
digitalWrite(LED3, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED3 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime = 2sec");
delay(delay2); // wait for 2 seconds
digitalWrite(LED2, LOW); // turn the LED off by making the voltage LOW
lcd.setCursor(0, 0);
lcd.print("LED2 = OFF");
lcd.setCursor (0, 1);
lcd.print("DelayTime =2sec");
delay(delay2); // wait for 2 seconds
if (digitalRead(BTN2) == LOW)
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("VEMKIJINA UKAXLE");
lcd.setCursor (0, 1);
lcd.print("was completed");
delay(delay3);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" gamoushvi ");
lcd.setCursor (0, 1);
lcd.print(" shemdegi ");
digitalWrite(LED5, LOW);
digitalWrite(LED6, LOW);
if (digitalRead(BTN2) == LOW) // Will be executed while button on pin 1 is pressed and therefore pin 1 is connected to GND
lcd.clear();
digitalWrite(LED1, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(LED2, HIGH);
digitalWrite(LED3, HIGH);
digitalWrite(LED4, HIGH);
digitalWrite(LED5, HIGH);
lcd.setCursor(0, 0);
lcd.print(" ALARM! ");
lcd.setCursor (0, 1);
lcd.print("Emergency Break!");
delay(delay10); // wait for 10 seconds
}
}
I have tried many times and a lot of options, let me know, after what line I should insert this code?
Let me ask you: what did you really learn over the past days?
You always quote my whole reply - why at all that redundancy?
You always skip back to not using code tags and I have no intention to assist you further as I have the impression you just do something, no matter what and then expect me to do the job for you.
It is your application and not mine, for me it begins to be a waste of time. You were given so many information, that you should be able to go on your own now - provided for that you are really putting efforts in learning how to program.
I don't see that effort at all.
All the fields which have to be learned are listed in my previous postings.
rpt007:
Let me ask you: what did you really learn over the past days?
. . .
He certainly hasn't absorbed the information in Reply #11.
Don
floresta:
He certainly hasn't absorbed the information in Reply #11.Don
look )))
look )))
What should that mean?
At least the Karma point system seems to work for you. I don't have an idea why, but apparently it does.
rpt007:
. . .
At least the Karma point system seems to work for you. I don't have an idea why, but apparently it does.
As of Reply #53 he has a total of 37 posts in 3 threads. In none of those threads did he offer any answers, only questions (and several strings of parentheses). The Karma point system has absolutely no valid significance.
Don
floresta:
As of Reply #53 he has a total of 37 posts in 3 threads. In none of those threads did he offer any answers, only questions (and several strings of parentheses). The Karma point system has absolutely no valid significance.Don
what am I supposed to do?
what am I supposed to do?
i try it , but it did not work, this place ... I teach with your help ...
I do not have money to order the code ...I need it for my fascination....
Goodbye and we'll see us, when you have learnt to do something on your own.
Got excited to see a long thread about the 1602 LCD that I just started playing with.
How disappointing.
Well, it's quite encouraging to see such good people put up for so long with such an obstinate poster.
@INTP:
If you have questions / problems about your LCD 16x2, you're welcome to post them in a new thread.
You will be assisted when one can see that you bring in your will and some efforts to learn to manage it on your own at the end of a day.
So don't hesitate.