A collection of tutorials that show you how to control DC motors using an Arduino Micro Controller.
How the motors are controlled is hardware dependent.
Control a DC motor with a L298N. –
How to connect your “L298N Dual H-Bridge Motor Controller” to “Arduino Uno” –
Code explanation of l293d motor driver Arduino tutorial –
How to get started with L293D motor shield –
Understanding How to Control DC Motors in Projects – Detailed and simple
Controlling DC Motor Speed and Direction with push-buttons – A follow on to the tutorial above.
IR Controlled DC Motor using Arduino– https://circuitdigest.com/microcontroller-projects/ir-controlled-dc-motor-using-arduino – Shows how to control a motor with a relay and IR detector.
The code to do this is just below.
) Rotate DC motor forward and reverse at set speed (withspeed control)
[Code]
/*this program will rotate DC motor forward for 5 sec
at 40%speed then stop for 2 sec and again rotate motor reverse for
5 sec at 80% speed continuously
*/
#include<DC_Motor.h>
DC_Motor motor2(9, 10, 1);
voidsetup()
{
}
void loop()
{
motor2.set_speed(40);
motor2.forward_with_set_speed();
delay(5000);
motor2.motor_speed_zero();
delay(2000);
motor2.set_speed(80);
motor2.reverse_with_set_speed();
delay(5000);
motor2.motor_speed_zero();
delay(2000);
}
]