i have model train and i want to stop it at the train station when it arrives. i have ultrasonic sensor, dc motor, and arduino uno. plz guys help me for program it.
the motor is in train. i have battery to power the train. i am going to put arduino on train and power it with 9 volt battery. and stick ultrasonic sensor on left side of the train so that if train arrives at station then ultrasonic sensor will sense it. but i want to program it like if the train stops at station after 5 sec i want that train to run again. plz guys help me to program it.
Can you read the sensor and print the value that it returns ?
How are you powering the motor ? Unless the motor is tiny do not power it from the Arduino pins directly as they cannot supply much current. Even if the motor is tiny there are other reasons to use an external power supply and switch the motor using a relay, transistor or MOSFET.