This Arduino project allows you to control the movement of a robot using serial communication. You can send commands to move the robot forward, backward, left, or right, as well as stop it and adjust its speed. The project uses two DC motors connected to an L298N motor driver.
- Control Directions: Move the robot forward, backward, left, or right.
- Speed Control: Adjust motor speed using a simple level system (1-9).
- Stop Functionality: Instantly stop the robot's movement.
- Arduino (e.g., Uno, Nano)
- L298N Motor Driver
- DC Motors (x2)
- Power Supply (for motors)
- Serial Communication Interface (e.g., USB cable)
enA
(PWM control): Pin 5in1
(Motor direction control): Pin 8in2
(Motor direction control): Pin 9
enB
(PWM control): Pin 6in3
(Motor direction control): Pin 10in4
(Motor direction control): Pin 11
-
Clone the repository:
git clone https://github.com/techdeiyo/mire.btcar
-
Upload the code to your Arduino:
- Open the
motor_control_serial.ino
file in the Arduino IDE. - Select your Arduino board and the correct COM port.
- Upload the sketch.
- Open the
-
Connect your motors and power supply as per the pin connections mentioned above.
Once the code is uploaded, open the Serial Monitor in the Arduino IDE, set the baud rate to 9600
, and use the following commands:
F
: Move forwardB
: Move backwardL
: Turn leftR
: Turn rightS
: Stop movement1-9
: Set speed level (1 is slowest, 9 is fastest)
- To move forward at speed level 5:
F 5
- To turn right at the current speed:
R
- To stop the robot:
S
- Adjusting Speed: Modify the
speedA
andspeedB
variables to set a default speed. - Expanding Commands: You can expand the
switch-case
block in theloop()
function to add more commands or actions.
This project is licensed under the MIT License. See the LICENSE file for details.