I am new to Arduino and have a small query. I am building a simple system that switches on a motor and switches it off after some time and repeats this in a loop.
The Arduino that I am using is a "DIY UNO Play Breadboard -ATMEGA328P with FT232 Breakout Board" (Rs. 825, or 12ドル.38USD, from Mangalore). The Arduino board is similar in size to a Nano but without USB. The FT232 board has a USB B port on one end and serial pins on the other. picture of boards and cable My query is whether I should connect the positive end of battery supply to the motor and then connect in series using a motor controller circuit to port 7 and connect the negative terminal to the gnd port.
Or do I need a separate voltage source for my Arduino, because this Arduino has no built in USB ports.
This is my code to switch on and switch off the motor:
int motorPin = 7;
pinmode(motorPin,OUTPUT);
digitalWrite(motorPin,HIGH); //turn motor on
delay(500); //wait
digitalWrite(motorPin,LOW); //turn motor off
delay(500); //wait
-
Can you please specify operating voltage/current rating of your motor. and some info related to your motor controller circuit.ARK– ARK2016年04月16日 20:26:50 +00:00Commented Apr 16, 2016 at 20:26
-
My motor is a 5V motor and this is the circuit that I want to build: instructables.com/files/orig/F5O/D77S/I0VOVRVX/…qwerty– qwerty2016年04月17日 00:26:48 +00:00Commented Apr 17, 2016 at 0:26
2 Answers 2
Using same Voltage supply to power Arduino Board and motor simultaneously is usually not a good practice.
So, what you can do is use separate batteries to power Arduino and motor as shown in image below enter image description here However you can also power arduino and motor from single power supply, but in this case you should first think of current ratting of your battery and current consumption of your Arduino (normally 500mA) and motor. As shown below, enter image description here Hope it help. Any question Comment below.
-
thanks for answering. Just another doubt, why can't I connect the positive terminal of the battery to the Vin Port.qwerty– qwerty2016年04月17日 12:50:07 +00:00Commented Apr 17, 2016 at 12:50
-
oh, really sorry, did a mistake there. edited. you are right. you actually have to connect to vin which in voltage input port whereas 5V is a voltage output port.ARK– ARK2016年04月17日 16:26:10 +00:00Commented Apr 17, 2016 at 16:26
-
Last doubt. Do I need to connect the negative terminal in the first diagram of the battery connected to motor to the gnd pin of the Arduino or will it work without the connection?qwerty– qwerty2016年04月19日 15:58:19 +00:00Commented Apr 19, 2016 at 15:58
-
you have to. It wont work without that. What we are doing there is called common ground. All GNDs in your circuit must be connected.ARK– ARK2016年04月19日 17:19:10 +00:00Commented Apr 19, 2016 at 17:19
You can use the same power supply for both if it can source enough current for both; USB ports usually can not. But what you must not do is try to supply motor current through the Arduino, from any power supply. You need the Arduino to control a transistor switch which manages the motor current.