Train related problem

Hi, I am making a train model that stops when a object comes front of it so I took a code of a project which uses ultrasonic sensor and buzzer when the object is in 50cm distance it buzzes i reduced it and it is working but i did vice-versa that when a object is there it stops else it buzzes it also worked.
Now, instead of buzzer i want to attach motor there so i want to ask did I need a motor driver for it.
I am using Arduino Nano with 9V power supply.

Chetan_:
Now, instead of buzzer i want to attach motor there so i want to ask did I need a motor driver for it.

Yes.

I am using Arduino Nano with 9V power supply.

You may also want to fix that. A 5V supply keeps your Nano a lot happier in the long run.

wvmarle:
You may also want to fix that. A 5V supply keeps your Nano a lot happier in the long run.

Beat me to it! :grinning:

No you didn't - I saw it and decided not to comment; I am just getting jaded re-phrasing the story again and again. :roll_eyes:

Make it into a copy/paste answer then. Saves a lot of effort :slight_smile:

That is exactly what I have! It is still tedious to edit/ adjust it to the particular circumstance!

The clear blunder is not comprehending what the "Vin" or "RAW" terminal is. It is essentially an ornament provided in the very beginning of the Arduino project when "9V" power packs were common and this was a practical way to power a lone Arduino board for initial demonstration purposes. And even then it was limited because an unloaded 9 V transformer-rectifier-capacitor supply would generally provide over 12 V which the regulator could barely handle.

If powering from batteries, as long as the battery pack cannot exceed 5.5 V, this must be connected to the 5 V pin.

Nowadays, 5 V regulated switchmode packs are arguably the most readily available in the form of "Phone chargers" and switchmode "buck" regulators are cheap on eBay so these can be fed into the USB connector or 5 V pin to provide adequate power for most applications. Unfortunately, many tutorials or "instructables" are seriously outdated or misleading and have not been updated to reflect the contemporary situation.

-------------- ***** --------------

The "Vin" or "RAW" terminal is essentially a legacy part, some "clones" such as the "RoboRed" and more sophisticated Arduinos do incorporate an actually functional switchmode regulator but it should simply be ignored on the older designs. :grinning:

-------------- ***** --------------

The obsolete tutorials on the Arduino site and others imply that the largely ornamental "barrel jack" and "Vin" connections to the on-board regulator imply that this is a usable source of 5 V power. This is absolutely not the case. It is essentially only for demonstration use of the bare board back in the very beginning of the Arduino project when "9V" transformer-rectifier-capacitor power packs were common and this was a practical way to power a lone Arduino board for initial demonstration purposes. And even then it was limited because an unloaded 9 V transformer-rectifier-capacitor supply would generally provide over 12 V which the regulator could barely handle.

If you are asking this question, it is highly likely that you will wish to connect something else. In which case, the answer is regulated 5 V.

This is because the on-board regulator is essentially capable of powering only the microcontroller itself and no more than a couple of indicator LEDs. The on-board regulator might be able to power a few other things if it had a heatsink, but on the Arduinos, it does not.

A practical power supply for the Nano (or UNO, Pro Mini, Leonardo etc.) is a "phone charger" with a USB output connector for 5 V, generally up to a couple of Amps though you can not feed more than 500 mA through the USB connection.

If you want to power it from 12 V or a car system, you need a 5 V switchmode "buck" regulator to supply the 5 V.

"Powering my uno R3" Powering my uno r3 - #5 by Paul_B - General Electronics - Arduino Forum

-------------- ***** --------------

You are just as likely trying to run something else that needs the 5 V as well as the Nano board itself. The on-board regulator of the UNO/ Nano/ Pro Mini/ Leonardo is only suitable for running the microprocessor itself as a demonstration; that was all it was ever provided for; not any other components. :astonished:

If you are connecting anything else - displays, relay boards, whatever - you need a switchmode regulator module to provide 5 V power. These are readily and cheaply available on eBay and such. It is unfortunate that you did not realise this to start with as it may delay your project, but it should have been part of your planning.

-------------- ***** --------------

This expression seems to come up here often - "powered by Arduino". It is a very strange concept, suggesting a very limited understanding of electronics.

An Arduino - such as a UNO, Nano, Pro Mini, Leonardo and similar - in no way resembles a power supply. A "power supply" is a component you plug into a "power point" or "utility outlet". Or devices may be powered by a battery of suitable capacity. But that and an Arduino are totally different things.

The confusion is usually encouraged by descriptions in the Arduino references that there is an on-board regulator on these boards. This is true - there is a regulator on the board and it can be used under limited circumstances to power the Arduino board and only the Arduino board. Essentially nothing else as the regulator, whatever its rated capacity, has no effective heatsink and will overheat and (hopefully safely) shut down if required to provide more current than the microcontroller itself and a few indicator LEDs at 10 or 20 mA each.

If you power the Arduino versions which have one, with 5 V via the USB jack, then up to the limit of the on-board protective fuse and power switching circuitry, you can pass the 5 V through to the "5V" terminal on the board and use it to power other devices - such as LEDs - up to the limit of that fuse, nominally 500 mA. But in general, the Arduino is simply not a "power supply" in any sense, so referring to "powering" something by it is meaningless.

As an aside, everything above applies to the thing described as a "MB102 power supply module" in its various versions. You can use it to supply 5 V to a few logic ICs or an ATMega328 chip and a few indicator LEDs at 10 or 20 mA each. That is its purpose. If you need to power something that does not fit on the breadboard or requires more than 100 mA, then you need a suitable power supply. If you can find the adapter, you can plug a 5 V power supply such as a "phone charger" into the USB port on the MB102 power supply module and have it reticulate that 5 V to the side rails on the motherboard up to 500 mA or a little more; this is its purpose - a convenient power adapter; not a power "supply". :grinning:

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Including how you connect power to the circuit.

What scale model railway?

Thaanks.. Tom... :slight_smile: