Arduino UNO and Cytron Motor Driver Controlled Two-Wheel Mobile Robot
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This document provides a detailed overview of a two-wheel mobile robot circuit. The circuit includes an Arduino UNO microcontroller, a Cytron motor driver, two power window motors, and a LiPo battery. The Arduino UNO controls the motors via the Cytron motor driver, enabling the robot to move forward, backward, turn left, turn right, and stop.
Component List
Cytron Motor Driver
- Component Name: Cytron Motor Driver
- Description: Motor driver for controlling two DC motors.
- Pins: m1b, m1a, b+, b-, m2a, m2b, dir1, pwm1, dir2, pwm2, gnd
Arduino UNO
- Component Name: Arduino UNO
- Description: Microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
Power Window Motor 1
- Component Name: Power Window Motor
- Description: DC motor used for driving the robot's wheels.
- Pins: Neutral, Power
Power Window Motor 2
- Component Name: Power Window Motor
- Description: DC motor used for driving the robot's wheels.
- Pins: Neutral, Power
LiPo Battery
- Component Name: LiPo Battery 2200mAH 30C
- Description: Rechargeable battery providing power to the circuit.
- Pins: VCC, GND
Wiring Details
Cytron Motor Driver
- m1b connected to Neutral of Power Window Motor 2
- m1a connected to Power of Power Window Motor 2
- b+ connected to VCC of LiPo Battery
- b- connected to GND of LiPo Battery
- m2a connected to Neutral of Power Window Motor 1
- m2b connected to Power of Power Window Motor 1
- dir1 connected to D8 of Arduino UNO
- pwm1 connected to D9 of Arduino UNO
- dir2 connected to D12 of Arduino UNO
- pwm2 connected to D11 of Arduino UNO
- gnd connected to GND of Arduino UNO
Arduino UNO
- D8 connected to dir1 of Cytron Motor Driver
- D9 connected to pwm1 of Cytron Motor Driver
- D12 connected to dir2 of Cytron Motor Driver
- D11 connected to pwm2 of Cytron Motor Driver
- GND connected to gnd of Cytron Motor Driver
Power Window Motor 1
- Neutral connected to m2a of Cytron Motor Driver
- Power connected to m2b of Cytron Motor Driver
Power Window Motor 2
- Neutral connected to m1b of Cytron Motor Driver
- Power connected to m1a of Cytron Motor Driver
LiPo Battery
- VCC connected to b+ of Cytron Motor Driver
- GND connected to b- of Cytron Motor Driver
Code Documentation
/*
* Arduino Sketch for Two-Wheel Mobile Robot
* This code controls a two-wheel mobile robot using a Cytron motor driver.
* The robot can move forward, backward, turn left, turn right, and stop.
*/
// Pin definitions
const int pwm1 = 9; // PWM pin for motor 1
const int dir1 = 8; // Direction pin for motor 1
const int pwm2 = 11; // PWM pin for motor 2
const int dir2 = 12; // Direction pin for motor 2
void setup() {
// Initialize motor control pins as outputs
pinMode(pwm1, OUTPUT);
pinMode(dir1, OUTPUT);
pinMode(pwm2, OUTPUT);
pinMode(dir2, OUTPUT);
}
void loop() {
// Example movements
moveForward();
delay(2000); // Move forward for 2 seconds
stopRobot();
delay(1000); // Stop for 1 second
moveBackward();
delay(2000); // Move backward for 2 seconds
stopRobot();
delay(1000); // Stop for 1 second
turnLeft();
delay(1000); // Turn left for 1 second
stopRobot();
delay(1000); // Stop for 1 second
turnRight();
delay(1000); // Turn right for 1 second
stopRobot();
delay(1000); // Stop for 1 second
}
void moveForward() {
digitalWrite(dir1, HIGH); // Set motor 1 forward
analogWrite(pwm1, 255); // Full speed
digitalWrite(dir2, HIGH); // Set motor 2 forward
analogWrite(pwm2, 255); // Full speed
}
void moveBackward() {
digitalWrite(dir1, LOW); // Set motor 1 backward
analogWrite(pwm1, 255); // Full speed
digitalWrite(dir2, LOW); // Set motor 2 backward
analogWrite(pwm2, 255); // Full speed
}
void turnLeft() {
digitalWrite(dir1, LOW); // Set motor 1 backward
analogWrite(pwm1, 255); // Full speed
digitalWrite(dir2, HIGH); // Set motor 2 forward
analogWrite(pwm2, 255); // Full speed
}
void turnRight() {
digitalWrite(dir1, HIGH); // Set motor 1 forward
analogWrite(pwm1, 255); // Full speed
digitalWrite(dir2, LOW); // Set motor 2 backward
analogWrite(pwm2, 255); // Full speed
}
void stopRobot() {
analogWrite(pwm1, 0); // Stop motor 1
analogWrite(pwm2, 0); // Stop motor 2
}
This code initializes the motor control pins as outputs and provides functions to move the robot forward, backward, turn left, turn right, and stop. The loop function demonstrates example movements with delays.