Hi! Can you please help me with my code?
I Made an Elevator Arduino Code and Used The Deley Fonction To Close The Door automatically after few seconds. it seemed to have worked but when I tried to go for the Mills approach my simulation ( wich was done it proteus 8 ) didn't work.
both my Codes are down Below , any help or advice will be much appreciated.
First Code :
void loop() { if (doorOpen && !doorClosing) { delay(doorDelay); closeDoor(); delay(50); } }
Converted To Mills () :
void loop()
{
static long doordelayMillis=millis();
static long closedoorMillis=millis();
if (doorOpen && !doorClosing && (millis()-doordelayMillis>doorDelay))
{
//delay(doorDelay);
if(millis()-closedoorMillis>50){
closeDoor();
//delay(50);
closedoorMillis=millis();
}
doordelayMillis=millis();
}
}
drmpf
June 3, 2021, 8:32am
2
Check out my tutorial on How to write Timers and Delays in Arduino which has millis() sketches and other ways of writing various type of delays/repeats
The easier you make it to read and copy your code the more likely it is that you will get help
Please follow the advice given in the link below when posting code , use code tags and post the code here
See also FAQ - Arduino Forum for general rules on forum behaviour and etiquette.
Hello,
Welcome to the Arduino Forum.
This guide explains how to get the best out of this forum. Please read and follow the instructions below.
Being new here you might think this is having rules for the sake of rules, but that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of posts while we try to get you to tell us what we need in order to help you, which is fru…
@theguy171 Please post the complete sketch of your best attempt to use millis() for timing in your project
system
Closed
October 1, 2021, 8:55am
5
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.