how do i replace delay with millis in this code

ok. thanks for the detailed explanation. i will try