Need Help connecting stepper motor & RGB sensor together

For my project my car have to move once the rgb sensor detect the color in an interval, so far I was able to move my motor and my sensor also work fine but once I connect them together on my cnc shield v3 the motor stop moving when my color detecting function start.
I don’t know what’s the problem on software or hardware side, can someone please help me?
the component I use are as followed:
stepper motor NEMA17
cnc shield v3 for my a4988 drivers
TCS230 RGB color sensor
I’ve attach my code to the post if you would like to view it.

RGB_Tracking_Car.ino (2.91 KB)

More members will see your code if posted properly. Read the how get the most out of this forum sticky to see how to properly post code. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code in code tags.

You have 600 milliseconds of delay() in loop() so your maximum speed is 1.66 steps per second. If a revolution is 200 steps, that’s about one revolution every two minutes. If you are using microstepping, it’s even slower. Could be half an hour per revolution! I think your delays are excessive.

If the delays are necessary, use millis() to schedule the reading of the colors. Read one color each timing cycle.

Here are some non-blocking timing tutorials:
Several things at a time.
Beginner's guide to millis().
Blink without delay().

Thank you all very much for the help, I appreciate it. Next time I'll read the rules before posting :slight_smile: my project is good to go now

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.