It's actually a digital signal which is constantly pulsing on and off very quickly (several hundred times per second). Now the voltage between the wiper terminal of potentiometer and Gnd determines the PWM voltage at pin no 6 and as wiper terminal is rotated, voltage at analog pin A0 changes causing change in speed of motor.Ĭomplete working of this Arduino Based Bi-directional Motor Speed and Direction control is shown in the Video below with the Arduino Code.You seem to have misunderstood PWM here.
Mosfet is switched on and off at high PWM frequency voltage and since motor is connected in series with the drain of mosfet, PWM value of voltage determines the speed of motor. Gate of MOSFET is connected to PWM pin 6 of Arduino UNO. So current do not flow from positive terminal of battery to negative terminal through motor and thus it does not rotate. And thus both relay is now in NO position. In this case current flows to the base of both transistors due to which both transistor turns on (acts like an closed switch). This causes anticlockwise rotation of motor But this time current flows from relay B to relay A. So current flows from positive terminal of battery to negative terminal of battery through motor. While other relay (RELAY A) remains in NC position. Now current easily flows to relay coil from Vin pin through transistor which turn this relay (RELAY B) on and switch of this relay is thrown to NO position. So current flows from positive terminal of battery to negative terminal through motor i.e., current flows from relay A to relay B. While other relay (RELAY B) is still in NC position. Now current easily flows to relay coil from Vin pin through this transistor which turn this relay (RELAY A) on and switch of this relay is thrown to NO position. In this case some current flows to the base of transistor through pressed push button which turns it on. In this case no current flows to the base of transistor, hence transistor remains off ( acts like an open switch) due to which no current flows to relay coil from Vin pin of Arduino. Both pins( 2, 3 ) of Arduino will remain always high. Operation of this 2-way Motor Control circuit is simple. Working of Arduino Controlled Bi-directional Motor: Thus there is no over current problem in Arduino. **Vin pin of Arduino can supply maximum current = 200mA. If both relays are energized, current= 30*2=60 mA So current need to turn on the relay = 12/400 Amps = 30 mA Resistance of relay coil is measured using a multimeter which turn out to be = 400 ohms MOSFET is switched on and off at high frequency voltage and since motor is connected in series with the drain of MOSFET, PWM value of voltage determines the speed of motor. MOSFET is required to control the speed of motor.
Check the complete Arduino Code at the end.
Connect Potentiometer's end terminal to 5v pin and Gnd pin of Arduino respectively.Connect diode across relay exactly as shown in figure.
Connect source of MOSFET to negative terminal of battery and to Ground pin of Arduino UNO.Connect normally open terminal of both relay to drain terminal of MOSFET.Connect normally closed terminal of both relays to positive terminal of battery.