I have the above sketch which prints to the DF Robot I2C LCD and also sends multi ADC values over serial.
The function is currently a demo and the printed text will be changed at a later date, the ADC values will be used later on in the code, they will not be printed to the LCD.
The LCD function is an example from DF Robot but it uses multiple delay functions, I need to remove these so the rest of the code works as intended, I have tried experimenting with millis and if statements as found in the blinkWithoutDelay example but I am not sure where to put them so it is not working.
Currently the delays are crucial to the timing of the scrolling text, the progress bar and the delay between the scrolling text and the progress bar. What is the best way to remove the delays in the above code?
the basic principle of doing mutliple things at the same time is to execute
a tiny small step from "thing A"
then
a tiny small step from "thing B"
then
a tiny small step from "thing C"
etc.
etc.
the code you have posted is a demo-code that just shows some things on the LCD. Just fr demonstration.
Your real code will do something different.
You should describe in detail what you really want to do.
The only thing you can re-use from the demo-code a single lines like
dfr0554.print(...
dfr0554.setCursorPosition(0, 10);
The rest of it changes anyway. With using delay() and without using delay().
The demo-code has this principle
stay inside loop "A" to print the character of the long string
stay inside loop "B" to count up a timer
doing multiple things like display some text and values
and reading in ADC or button-presses at the same time
is coded with one big loop
this loop is function loop() itself
void loop()
read ADC-channels
do something with ADC-values
if "printing long string is active"
print a single character
increase index "i"
if timer is active
print new value of timer
increase timervalue
the lines above are repeated ( "looped" ) through function loop() itself
I'm very sure that you can learn a lot from
reading this tutorial:
It is easy to understand and has a good mixture between explaining important concepts and example-codes to get you going. So give it a try and report your opinion about this tutorial.