Interesting chosen words "rewrite my delays as millis".
Yes sure using millis needs to some extent rewriting the code.
You can see your functionality as different modes of operation are needed
if left bumper is hit
change from
mode 1: go_forward
to
mode 2: go_backwards for a 1000 milliseconds
after that change to
mode 3: spin_right for 400 millisecods
after that change back to
mode 1: go_forward
if right bumper is hit
change from
mode 1: go_forward
to
mode 2: go_backwards for a 1000 milliseconds
after that change to
mode 4: spin_left for 400 millisecods
after that back to
mode 1: go_forward
This means you have two sequences of certain modes of operation
that shall be run trhough always in the same order
These sequences with different modes of operation are invoked by the event
left bumper hit / right bumper hit
In Programming something like this is called a state-machine.
Each mode of operation is a "state" the "machine" is in.
There are events like
- "sensor-value becomes "HIGH"
or - sensor-value goes above a threshold-value
or - sensor-value goes below a threshold-value
or - a certain amount of time has passed by
This is what your code is doing depending on events happening change the mode of operation
= change the state
The event a certain amount of time has passed by (since a reference-point in time)
is something that you know from your everyday life
example
baking a frosted pizza. The cover says "baking time 10 minutes"
You can start at any time of the day to put the frosted pizza into a hot oven
You take a look onto your watch and make a snapshot of time inside your head
= the reference point in time
for example putting the frosted pizza into the oven at the time 13:05
baking time is ten minutes means at time 13:15 pizza is ready to eat
another day you do it at time 14:37
baking time is ten minutes means at time 14:47 pizza is ready to eat
etc. etc.
you check the time that has passed by since a reference-point in time
The rest of the details is explained in this tutorial
How to code different modes of operation named state-machine are explained here
So start reading in these tutorials and ask questions if you have any question
best regards Stefan