The speed of the motor can take values from 0-255. Inside the setup() function, we will use the setSpeed() method on the motor instance and pass the speed of the motor as an argument inside it. In our case we connected the dc motor with M3 hence ‘3’ is specified as the parameter inside it. Next we will create an instance of AF_DCMotor called motor and specify the motor port we are connecting our motor with. This basic sketch will show us how to control a DC motor’s speed and direction of rotation using the L293D motor driver shield with the AFMotor.h library. Copy the code given below in that file and save it. Open your Arduino IDE and go to File > New. There are different ways we cam power both the driver shield and the motors. Now let us discuss another important aspect which is the power supply connections and considerations. One important point to note here is that this driver shield supports motors with voltages between 4.5-25V only. If using a unipolar stepper motor the GND terminals will be connected to the centre taps of the stepper motors. The M1,M2 terminals will connect stepper motor 1 and M3,M4 will connect stepper motor 2. Additionally, we can also connect two unipolar/bipolar stepper motors at these terminals instead. We will be able to connect four DC motors rated at 4.5-25 V at these terminals. At both the left and right sides you can view five pin terminals. You will be able to connect two servo motors at these terminals as a single servo motor comes with three wires that need to be connected. At the top left corner you can view two three pin headers. Two servo motors, Four DC Motors and Two stepper motor connections can be found on this motor driver shield.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |