DC motor controlled by IR reflect sensor

Arduino Nano M2 connect IR reflect sensor and DC motor DC motor keeps spinning until IR sensor meets a reflective surface; it stops the motor for 3 seconds; then spin it again until meet next reflective spot and do the same 3 seconds stop and so on. Please help write the code. Please guys. Many thanks (note: foto shows different arduino but the one I have is Nano M2)

If you just want someone else to write code for you then ask the moderator to move this Thread to the Gigs and Collaborations section.

If you want help with doing your own programming, this is the place.

What experience of Arduino programming do you already have? If you are just starting out I suggest you study the various example sketches that come with the Arduino IDE. All the parts that you need for your project are probably in them.


Many thanks; I just started with Arduino..Only know the LED blink sketch. I got good experience in Animatronics (the mechanical part), but weak on programming because it took me quite a time to digest the simple LED sketches...I guess people brain like a radio, tuned on certain channels but not others..was hoping someone help with this code because I did all the mechanics already...If this tread is not the one; maybe as you said , I will look for the division you mentioned and try to know how to shift the tread.,..