![]() You just have to replace the function digitalWrite with analogWrite in last weeks code. This is because pins 10 and 11 are PWM pins. Remember, I asked you to connect the enable pins of H-bridge to pins 10 and 11 of Arduino. ![]() You can just reuse the same circuit from last week. If you pass a value between 1 and 254, then the speed of the motor will vary accordingly. If you pass 0, then the motor will stop and if you pass 255 then it will run at full speed. Remember the value can be between 0 and 255. The speed of the motor depends on value that was passed to the analogWrite function. To control the speed of the motor, all we need to do is to replace digitalWrite function on L293D enable pins to analogWrite. In Arduino Uno, it works on pins 3, 5, 6, 9, 10 and 11. This function takes a value between 0 and 255 and doesn’t work on all pins in Arduino. If not, then checkout the PWM tutorial from Arduino reference. If you have tried out the LED fade example in Arduino, then you already know how to use it. In Arduino, the analogWrite function allows you to generate a PWM wave in a pin. ![]() Analog Writeīefore we go ahead, we need to know about analogWrite function in Arduino. Also I will talk about how we can encapsulate the entire logic into an Arduino Library. This week we will see how we can control the speed of the motor as well using the IC. Last week, I explained how we can control the direction of DC motors using the H-Bridge L293D IC. In this article we will see how we can control the speed of the DC motor using Arduino. ![]() This is part 4 of my “ Building Robots using Arduino” tutorial series, explaining how you can create robots using Arduino. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |