Generally we use servo motor for sweeping but we can do the same thing using any type of motor. Here in this project i'll explain how to do it using a L293d and DC motor.
This project will help us save costs by using DC motor instead of servo motors and still perform the sweeping function.
- DC motor
- jumper wire
- power supply
- Arduino UNO
Step 1: Connect the L293d and Motor With Arduino
In L293D shield 5 volt is required for enable purpose. Hence, we give 5 volt power supply.
If you want to increase the speed of sweeping then give 9-12 volt supply, to increase the speed of motor, otherwise 5 volt is enough for it. Connect the output pin of Arduino (which is connected to control the motor) to the L293D.
If you want to use mobile vibration motor for this operation, then don't use any motor driver shield or motor driver IC. Connect it directly to the output digital pin of your Arduino board.
Follow the hand drawn schematic to complete the circuit assembly.
Step 2: Upload the Code
Let's upload this code to your arduino board via arduino IDE.
Step 3: Understanding the Sweeping Part
Here, the sweeping part is controlled via analogWrite command in arduino. It should be less than 255 because arduino is a 8-bit microcontroller.
So we will get maximum value 2^8= 256 i.e 0 to 255 as the value starts from 0 hence we'll get maximum value 255.
Deploy DC motor to sweeping function in rotating head and multiple other places.