Outputting to a motor stops TOF sensors from working

Evening, I have a strange one here.

So I have 2 TOF sensors (VL53L1X) and a music box with a motor that you can pick up off amazon etc. So the overview is that TOF sensors read distance and when the distance goes below a certain value (defined into 4 values using a potentiometer) then it will see the music box off.

However as you can see from my serial output below once the motor is set off it "kills" the TOF so they no longer return any values. But then I power cycle the arduino and the it works again until triggered.

21:20:54.074 -> Potentiometer value is 4
21:20:54.120 -> Sensor One 2278
21:20:54.120 -> Sensor Two 1492
21:20:54.166 -> Potentiometer value is 4
21:20:54.213 -> Sensor One 2254
21:20:54.213 -> Sensor Two 1488
21:20:54.259 -> Potentiometer value is 4
21:20:54.305 -> Sensor One 196
21:20:54.305 -> Sensor Two 1488
21:20:54.351 -> Potentiometer value is 4
21:20:54.806 -> Sensor One 109
21:20:54.806 -> Sensor Two 0
21:20:54.806 -> Potentiometer value is 4
21:20:55.807 -> Sensor One 0
21:20:55.807 -> Sensor Two 0
21:20:55.807 -> Potentiometer value is 4
21:20:56.809 -> Sensor One 0
21:20:56.809 -> Sensor Two 0
21:20:56.809 -> Potentiometer value is 4
21:20:57.811 -> Sensor One 0
21:20:57.811 -> Sensor Two 0
21:20:57.811 -> Potentiometer value is 4
21:20:58.813 -> Sensor One 0
21:20:58.813 -> Sensor Two 0

Any ideas what it could be? I'm using a nano for this project.

Thanks in advance

Inadequate power supply and/or electrical noise on the power leads, for example trying to power the motor from the Arduino 5V.

Please post a wiring diagram (a photo of a hand drawn diagram is fine).

I had a feeling it may be inadequate power but I didn't want to admit it. I will draw up a diagram tomorrow and post it for information.

That is the first thing we look for, when the words "motor" and "Arduino" appear together in a post (often accompanied by the unsurprising but useless phrase "not working").

90-95% of the motor/Arduino problems reported on this forum are due to inadequate power supplies.

Yeah I kinda assumed as much. In a situation like this what would be used as a switchable power supply for a motor?

I have this connected to an 18650 battery so some kind of relay? Is there such a think as a silent relay?

Just asking questions until I'm able to put together a diagram

Cheers

That depends entirely on the motor. Tell us about yours.

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