How to use millis() like delays.
So i know how to make something blink with millis(), but I dont know how to make something where I need different delay values, for example:
digitalwrite(pin, HIGH);
delay(200);
digitalwrite(pin, LOW);
delay(500);
so I need to make a code that does this, but with millis(), is this possible?
thanks
8 Replies
you set up a variable for each "delay" you need
i.e.
prevPin1Time
, prevPin2Time
, etc.
then setup the various INTERVAL
values
https://wokwi.com/projects/436781592561891329
even better https://learn.adafruit.com/multi-tasking-the-arduino-part-1?view=allDelay function millis - Wokwi ESP32, STM32, Arduino Simulator
Run IoT and embedded projects in your browser: ESP32, STM32, Arduino, Pi Pico, and more. No installation required!
okay thanks so much
were you asking about a toggle button the other day?
yes, but I got It working
Or just do it like this.. https://wokwi.com/projects/398893457903582209
!delay(1) - Wokwi ESP32, STM32, Arduino Simulator
Run IoT and embedded projects in your browser: ESP32, STM32, Arduino, Pi Pico, and more. No installation required!
There's paramiters you can set to get the timing you desire.