East Anglia (UK)
Offline
Edison Member
Karma: 54
Posts: 1595
May all of your blinks be without delay
|
 |
« Reply #30 on: February 23, 2013, 02:53:17 am » |
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #31 on: February 23, 2013, 03:53:06 am » |
if (minute == 1&&j<1) { switch (lcd_key) // depending on which button was pushed, we perform an action case btnSELECT: {for(i=0;i<1;i++) lcd.setCursor(0, 1); lcd.print(" MOTOR OIL "); digitalWrite(led0, LOW); digitalWrite(led1, HIGH); digitalWrite(led2, LOW); break; } } if (minute == 1) { switch (lcd_key) // depending on which button was pushed, we perform an action case btnLEFT:
{for(j=0;j<1;j++) lcd.setCursor(0, 1); lcd.print(" Timer "); digitalWrite(led0, LOW); digitalWrite(led1, LOW); digitalWrite(led2, LOW); break; } }
I use "j" for checking on time t = 1 min if press button SELECT show lcd.print(" MOTOR OIL "); digitalWrite(led0, LOW); digitalWrite(led1, HIGH); digitalWrite(led2, LOW); and then press LEFT show lcd.print(" Timer "); digitalWrite(led0, LOW); digitalWrite(led1, LOW); digitalWrite(led2, LOW); use "j" if while min = 1 press SELECT and press LEFT and then press SELECT won't show lcd.print(" MOTOR OIL "); digitalWrite(led0, LOW); digitalWrite(led1, HIGH); digitalWrite(led2, LOW); because j = 1
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #32 on: February 23, 2013, 03:58:13 am » |
You have to use a timer. Press the button once to start the timer and then keep it held. Using "millis() - timer > 30000UL", it will check to see if the state has changed within that period. If it DOES change within that period, it will NOT do the action. Only when the first state and second state are equal will it do the action.
I didn't get your suggestion. I want to press and hole button until 30 sec it will doing next stage command.
|
|
|
|
|
Logged
|
|
|
|
|
Finland
Offline
Jr. Member
Karma: 1
Posts: 84
|
 |
« Reply #33 on: February 23, 2013, 04:15:03 am » |
I use "j" for checking on time t = 1 min if press button SELECT show
The point is that you could replace that for "loop" with j=1 and it would do exactly the same thing, always, after the "loop" has executed. Same thing with the other loop and i=1... We don't understand why do you run the loop once. I didn't get your suggestion. I want to press and hole button until 30 sec it will doing next stage command.
You save the first time stamp with millis() to a variable, and then keep comparing has the 30 second or 30 000 millisecond mark been reached. When the difference is greater than the limit you proceed with the next stage. Oh, wait, I just repeated the previous answer, sorry..
|
|
|
|
« Last Edit: February 23, 2013, 04:19:31 am by Chaul »
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #34 on: February 23, 2013, 04:26:03 am » |
I use "j" for checking on time t = 1 min if press button SELECT show
The point is that you could replace that for "loop" with j=1 and it would do exactly the same thing, always, after the "loop" has executed. Same thing with the other loop and i=1... We don't understand why do you run the loop once. I didn't get your suggestion. I want to press and hole button until 30 sec it will doing next stage command.
You save the first time stamp with millis() to a variable, and then keep comparing has the 30 second or 30 000 millisecond mark been reached. When the difference is greater than the limit you proceed with the next stage. Oh, wait, I just repeated the previous answer, sorry.. Ok thanks all for question. This code I simulate for maintance car every 800 Hrs,1200Hrs,2000Hrs,2400Hrs but in this case i use time for easy test I think my program it's OK but function press button it's not suitable I wan to press and hold 30 sec for working ,don't press and working
|
|
|
|
|
Logged
|
|
|
|
|
Finland
Offline
Jr. Member
Karma: 1
Posts: 84
|
 |
« Reply #35 on: February 23, 2013, 04:34:51 am » |
Ok thanks all for question. This code I simulate for maintance car every 800 Hrs,1200Hrs,2000Hrs,2400Hrs but in this case i use time for easy test
I think my program it's OK but function press button it's not suitable I wan to press and hold 30 sec for working ,don't press and working
It's up to you what you want it do after 30 seconds has passed. The hint we gave you just gives you the ability the measure that the time has passed. So, within that 30 seconds, do nothing, and after the condition returns true (> 30000UL), you do something. 30 seconds is a long time for holding a button though.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #36 on: March 05, 2013, 01:55:59 am » |
Hi all again  I have new problem Previously I use Vin 5 Volt ,pin3 on board arduino Uno to command in this code for working if (digitalRead(pin3) == HIGH) { static unsigned long lastTick = 0; if (millis() - lastTick >= 1000) { lastTick = millis(); second++; }
// Move forward one minute every 60 seconds if (second >= 60) { minute++; second = 0; // Reset seconds to zero }
// Move forward one hour every 60 minutes if (minute >=60) { hour++; minute = 0; // Reset minutes to zero }
if (hour >=2800) { hour=0; minute = 0; // Reset minutes to zero }
}
But Why I use other supply 5 V to command doesn't working ? (I use 24 V drop to 5 V by regulator zener diode circuit)
|
|
|
|
|
Logged
|
|
|
|
|
East Anglia (UK)
Offline
Edison Member
Karma: 54
Posts: 1595
May all of your blinks be without delay
|
 |
« Reply #37 on: March 05, 2013, 02:13:55 am » |
When you say "other supply" do you mean that you are using 2 power supplies ? If so, are the grounds of the 2 supplies connected ?
If that is not what you meant can you please explain more clearly ? An explanation of how the Arduino, the power supply/supplies and pin 3 are wired would also help.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #38 on: March 05, 2013, 02:32:33 am » |
When you say "other supply" do you mean that you are using 2 power supplies ? If so, are the grounds of the 2 supplies connected ?
If that is not what you meant can you please explain more clearly ? An explanation of how the Arduino, the power supply/supplies and pin 3 are wired would also help.
OK I use Arduino Uno supply by USB computer.I connect 1 relay board and previously i use Vin on board to command code if (digitalRead(pin3) == HIGH) { static unsigned long lastTick = 0; if (millis() - lastTick >= 1000) { lastTick = millis(); second++; }
// Move forward one minute every 60 seconds if (second >= 60) { minute++; second = 0; // Reset seconds to zero }
// Move forward one hour every 60 minutes if (minute >=60) { hour++; minute = 0; // Reset minutes to zero }
if (hour >=2800) { hour=0; minute = 0; // Reset minutes to zero }
} It's working but now I using 24 V supply one more (not supply arduino uno) for drop volt by regulator zener diode circuit to 5 V for use 5 V borad arduino instead but it's not working.
|
|
|
|
|
Logged
|
|
|
|
|
East Anglia (UK)
Offline
Edison Member
Karma: 54
Posts: 1595
May all of your blinks be without delay
|
 |
« Reply #39 on: March 05, 2013, 02:38:23 am » |
So the Arduino is powered via USB and the relay board is powered by a separate power supply. Are the grounds of the two supplies connected ?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #40 on: March 05, 2013, 02:43:22 am » |
So the Arduino is powered via USB and the relay board is powered by a separate power supply. Are the grounds of the two supplies connected ?
no Arduino is powered via USB and the relay board is powered via USB too, use pin 5V on board .
|
|
|
|
|
Logged
|
|
|
|
|
East Anglia (UK)
Offline
Edison Member
Karma: 54
Posts: 1595
May all of your blinks be without delay
|
 |
« Reply #41 on: March 05, 2013, 03:02:42 am » |
So what is the 24V supply doing ?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #42 on: March 05, 2013, 03:18:33 am » |
So what is the 24V supply doing ?
I have 24 volt supply but I want 5 V. I use zener diode regulator circuit 24 V to 5 V.
|
|
|
|
|
Logged
|
|
|
|
|
East Anglia (UK)
Offline
Edison Member
Karma: 54
Posts: 1595
May all of your blinks be without delay
|
 |
« Reply #43 on: March 05, 2013, 03:26:36 am » |
So, it works if you get power from the USB for both boards, but not if you use the 24V supply reduced to 5V by a Zener diode. Are you sure that you are actually getting 5V all the time. Is there any other form of regulation on the supply other than the Zener ?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #44 on: March 05, 2013, 03:57:46 am » |
So, it works if you get power from the USB for both boards, but not if you use the 24V supply reduced to 5V by a Zener diode. Are you sure that you are actually getting 5V all the time. Is there any other form of regulation on the supply other than the Zener ?
yep i sure i measure zener board 4.9 V when connect remain 4.7 V it's ok for volt but program doesn't work !!! I measure Volt on UNO board 5 V remain 4.5 V it's work HELP ME ??
|
|
|
|
|
Logged
|
|
|
|
|
|