I am looking to build a circuit with a HCSR04 ultrasonic sensor and a dc motor. When the sensor value gets below a certain distance, the motor will turn on. I have no problem with the code, just need some ideas on how to integrate these two circuits. I've tried just sticking the two ends of the motor wires between the 5V and GND on the breadboard, but that doesn't work well.
Attached are the two separate circuits, any advise would be appreciated!
leofelixzhu:
but that doesn't work well.
What does that actually mean?
You shouldn't power the motor from the Arduino: it's very likely to want too much current.
Have a look here for example.
Edit..... The combined circuit will look like the attached.
motor and ultrasonic.bmp (196 KB)
Thank you! I shall power the motor from a different source, and use a relay to let in the voltage.
You mean a transistor, not a relay, if you're talking about the component "Q" in the schematic.
Sorry, yes I meant to say a transistor or driver.
Like this one here: L298n DC Stepper Motor Driver Module Dual H Bridge Control Board for Arduino for sale online | eBay
So is the above device called a motor driver or is it just actually a transistor?
The one you show is usually called a "driver" yes. It's an h-bridge, which allows directional control of 2 motors. It's made up of transistors.
But if you haven't bought that one already, you could consider better more modern technology, such as this one. You could use this table to select the right driver: you need to check volts and amps are enough.
Trouble with the board you linked, is that its main component the L298 is very inefficient. It has a minimum loss of 2V and that goes to almost 5 at high current.... that waste goes out as heat, hence that huuuuuuuuuge heat-sink on there.
The Pololu drivers, and other makes, are more efficient and physically much smaller.
MIN loss of 2V?! Wow I did not know that. And I plan to use this system on a RC boat. Thank you for your input.
leofelixzhu:
MIN loss of 2V?!
Well 1.8 actually, min, up to 3.2 at 1A; but 4.9 at 2A. Also it weighs a ton with that heat sink, and I guess in a model boat, that could make a difference.
See pic attached, from datasheet.