Go Down

Topic: Need to power small dc motor car for specific distance and stop (Read 14092 times) previous topic - next topic


Thanks for the input
This car is by far the most complicated. Others are fully mechanical, forced air, mouse trap etc.
Jim, Thanks for the links. We'll try those tutorials in class.
MaJ, thanks for the specifics thats our level of operation. I think we'll go with your suggestions.
I'm sure we'll have more questions in the near future.
Les Bon Ton Roulet


Feb 12, 2013, 06:42 am Last Edit: Feb 12, 2013, 06:57 am by MaJiG Reason: 1
I am attaching a breadboard picture and a crude schematic, which has the motor connected to 3.3V as I believe you are using a 3V pager motor, yes?

You can have the students breadboard the project without the Hall Effect sensor like this:

*Run the wire from D12 to +5V to simulate the wheel being out of alignment.

*Download and run the code. The D13 (READY) should be OFF, indicating that you aren't ready to start.

*Move the D12 wire from +5V to GND, which simulates the magnet aligning. The D13 (READY) LED should come ON to indicate that the wheel is now aligned and we're ready to go.

*Press the GO button. The motor should start running.

*Now move the D12 wire between between GND and +5V ten times.

*After the tenth transition from HIGH to LOW (this number is a constant in the code), the motor should turn OFF.

You can test the setup and get everything working so that, when the Hall Effect comes in, you are already 90% done.  Be mindful of the heat of the motor.  It might not like running for more than 30 seconds or so.

The breadboard pic is generated by Fritzing here: http://fritzing.org/


Thanks MaJ
That's what we will do today.
The sensor is in the mail as of yesterday. 
I'll post back with our results tonight.
We'll probably have more questions too.
In the immortal words of Darnell Turner "That was a straight up Street Ballin move Willie."


BTW, you're going to need small powerful magnets. Like these http://www.amazon.com/Grade-Super-Strong-Neodymium-Magnets/dp/B001ANVAHI/ref=pd_cp_hi_1

They need to be axial. You would glue one with South toward the sensor and three with North toward the sensor.

Using four will balance the wheel and turn OFF the Hall Effect Detector, which is latching.

Willie the postman???

Keep me up updated...


OK we got the sensor and most of the circuit connected. We even think we understand what's going on. But here are our questions so far:
1. The code says D13 should have a LED to indicate ready but it is not shown in either diagram. We assume that the other end should be grounded but we are not sure of where to put it on the breadboard.
2. Our sensor has 3 leads the one in the diagram only has 2. According to the datasheet we think D12 should go to the output. The middle leg should go to ground and the input should should connect to 3V. Right? But again we are unsure of how to place it on the board.
3. Our go button is a spring loaded NO. Is that correct or does it need to operate in a closed position? 

Right, Willie the Postman... From the yard sale scene where Joy steals the ball from the game and Willie pops out his glass eye as a replacement.
My other favorite is Billie... "He can still be your brother, he just has to be an outside brother"
Thanks again for the help


Feb 18, 2013, 10:49 pm Last Edit: Feb 18, 2013, 10:51 pm by MaJiG Reason: 1
1)  The D13 pin has the on-board LED on the UNO. It is the one nearest d13.  There is nothing for you to connect.

2)  The diagram was using a reed switch for simplicity.  As you face the HED, the left-most pin is number 1, the middle pin is pin 2, and the right-most pin is pin 3.

pin 1 goes to +5V
pin 2 goes to GND
pin 3 goes to pin d12

I'll cook up another set of breadboard and schematic diagrams tonight.

You should probably test the HED individually just to see how it works.

I am attaching a breadboard  and schematic for the test circuit. You should see the LED come ON when the South pole of a magnet comes near the sensor, and the LED should turn OFF when a North pole comes near the sensor.  You can see how the sensor reacts to the magnet and you can also see how close your magnet needs to be to turn the sensor ON/OFF.

In the diagrams, I used a 4.8V battery pack, but you can just use jumpers from the Arduino 5V and GND.


Here's the final drawings. Everything is there.


You're our hero.
We'll work on it today and post some pics


Here's the final drawings. Everything is there.

The Uno product page list the current avaliblity of the 3.3v pin as only:

DC Current for 3.3V Pin   50 mA

I thought earlier in the thread the motor was estimated to require more then that?



That transistor is going to get hot. You may want to add a resistor at the emitter to ground. I don't know off hand of an actual value to use, so you may just want to use a 1K POT and adjust it.

Added: You may want to make it a darington pair, instead of a single transistor.
My GitHub:


Feb 20, 2013, 09:03 pm Last Edit: Feb 20, 2013, 09:06 pm by MaJiG Reason: 1
retrolefty, nice catch. Attaching mods. Karma bump.

HazardsMind, the motor is ON less than five seconds.


Feb 26, 2013, 06:19 pm Last Edit: Feb 26, 2013, 08:04 pm by GrisGris Reason: 1
Almost there... We think!!
But, We can't get the motor to stop.
The test circuit worked just as explained.
Now with the circuit set up as described, when the arduino is powered up the D13 LED flashes a couple of times and then lights up. (it does this whether the magnet is aligned near the HED or not when power is turned on)
Then when the go button is pressed the motor starts but continues to run regardless of the number of times the magnet is passed over the HED.
We're sure it is connected correctly but the one component we are not sure of is the transistor. The numbers on it are 2N3904-338 it's the only one we have right now.
We tried reversing the HES and the transistor to see if polarity was a problem but no luck.
We changed the number of rotations to 3 in the code just to make the tests quicker but other than that we have made no changes to the code.
But we're at a loss as to what to try next.


I hadn't noticed the power mod before the last post.
We are testing the setup with a 9V battery power source to the Arduino.
And all power sources connected as shown.
The transistor has not been hot at all. Could a bad transistor cause the problem we are seeing?


I hadn't noticed the power mod before the last post.
We are testing the setup with a 9V battery power source to the Arduino.
And all power sources connected as shown.
The transistor has not been hot at all. Could a bad transistor cause the problem we are seeing?

If your code is solid, the only other real possibilties would be a shorted transistor, broken HED, or the HED is not hooked up properly or needs some other type of hook up like a pullup resistor. Also, with hall effect sensors, it will only respond to a single pole. Make sure that your pole of the magnet is correct for the sensor.

I would separate that part and test it to make sure the arduino is actually seeing the HED trigger.


I would separate that part and test it to make sure the arduino is actually seeing the HED trigger.

We did the HED test that MaJ sent and it works so we eliminated that as a problem.
I think I'll run down to Radio Shack now and get another transistor in case that's it.
How would I isolate the HED to test it with the Arduino?

Go Up