An H-bridge is an electronic circuit that can drive the motor in both directions. To control the direction of the spin of DC motor, without interchanging the leads, you can use a circuit called an H-Bridge. The DC motor will spin with different speeds according to the value (0 to 250) received via the serial port. The 'if' statement in the next line simply does an analog write with this number, if the number is between 0 and 255. In the 'loop' function, the command 'Serial.parseInt' is used to read the number entered as text in the Serial Monitor and convert it into an 'int'. You need to enter a value between 0 and 255 in the Serial Monitor. When the program starts, it prompts you to give the values to control the speed of the motor. Arduino pin 3 is used to turn the transistor on and off and is given the name 'motorPin' in the sketch. The transistor acts like a switch, controlling the power of the motor. Motor Speed Controlįollowing is the schematic diagram of a DC motor, connected to the Arduino board. Motor will spin in full speed when the Arduino pin number 3 goes high. The transistor acts like a switch, controlling the power to the motor. Second, the striped end of the diode should be towards the +5V power line according to the arrangement shown in the image. The flat side of the transistor should face the Arduino board as shown in the arrangement. Take the following precautions while making the connections.įirst, make sure that the transistor is connected in the right way.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |