Arduino and L298P Motor Shield Controlled Robotic Car with LED Indicators and Bluetooth Connectivity
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to control a motorized vehicle with LED indicators and a piezo buzzer. The vehicle is controlled using an Arduino UNO and an L298P drive shield. The circuit also includes Bluetooth communication for remote control. The LEDs and piezo buzzer provide visual and audio feedback, respectively.
Component List
Motor and Wheels
- Description: Motor and wheel assembly for vehicle movement.
- Pins: VCC, GND
L298P Drive Shield
- Description: Motor driver shield for controlling the motors.
- Pins: B-, B+, A-, A+, GND, VIN
Battery 12V
- Description: Power source for the circuit.
- Pins: +, -
Resistor (1000 Ohms)
- Description: Current limiting resistor.
- Pins: pin1, pin2
LED: Two Pin (Red)
- Description: Red LED for visual indication.
- Pins: Cathode, Anode
LED: Two Pin (Blue)
- Description: Blue LED for visual indication.
- Pins: Cathode, Anode
Arduino UNO
- Description: Microcontroller for controlling the circuit.
- 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
Piezo Buzzer
- Description: Buzzer for audio feedback.
- Pins: pin 1, pin 2
Bluetooth HC-06
- Description: Bluetooth module for wireless communication.
- Pins: VCC, GND, TXD, RXD
Wiring Details
Motor and Wheels
Motor 1:
- VCC connected to A+ of L298P Drive Shield
- GND connected to A- of L298P Drive Shield
Motor 2:
- VCC connected to B+ of L298P Drive Shield
- GND connected to B- of L298P Drive Shield
L298P Drive Shield
- B- connected to GND of Motor 2
- B+ connected to VCC of Motor 2
- A- connected to GND of Motor 1
- A+ connected to VCC of Motor 1
- GND connected to - of Battery 12V
- VIN connected to + of Battery 12V
Battery 12V
-
- connected to VIN of L298P Drive Shield
-
- connected to GND of L298P Drive Shield
Resistors
Resistor 1:
- pin1 connected to Anode of Blue LED 1
- pin2 connected to D11 of Arduino UNO
Resistor 2:
- pin1 connected to Anode of Red LED 1
- pin2 connected to D10 of Arduino UNO
Resistor 3:
- pin1 connected to Anode of Red LED 2
- pin2 connected to D9 of Arduino UNO
Resistor 4:
- pin1 connected to Anode of Blue LED 2
- pin2 connected to D8 of Arduino UNO
Resistor 5:
- pin1 connected to pin 2 of Piezo Buzzer
- pin2 connected to D7 of Arduino UNO
LEDs
Blue LED 1:
- Anode connected to pin1 of Resistor 1
- Cathode connected to GND of Arduino UNO
Blue LED 2:
- Anode connected to pin1 of Resistor 4
- Cathode connected to GND of Arduino UNO
Red LED 1:
- Anode connected to pin1 of Resistor 2
- Cathode connected to GND of Arduino UNO
Red LED 2:
- Anode connected to pin1 of Resistor 3
- Cathode connected to GND of Arduino UNO
Arduino UNO
- D11 connected to pin2 of Resistor 1
- D10 connected to pin2 of Resistor 2
- D9 connected to pin2 of Resistor 3
- D8 connected to pin2 of Resistor 4
- D7 connected to pin2 of Resistor 5
- GND connected to Cathodes of all LEDs and pin 1 of Piezo Buzzer
Piezo Buzzer
- pin 1 connected to GND of Arduino UNO
- pin 2 connected to pin1 of Resistor 5
Bluetooth HC-06
- VCC connected to 5V of Arduino UNO
- GND connected to GND of Arduino UNO
- TXD and RXD not connected in this circuit
Documented Code
L298P Drive Shield Code
#include <AFMotor.h>
AF_DCMotor leftMotor(1);
AF_DCMotor rightMotor(2);
#define BLUE_LED 3
#define RED_LED 4
void setup() {
leftMotor.setSpeed(200);
rightMotor.setSpeed(200);
pinMode(BLUE_LED, OUTPUT);
pinMode(RED_LED, OUTPUT);
Serial.begin(9600);
}
void loop() {
if (Serial.available()) {
char command = Serial.read();
switch (command) {
case 'F':
leftMotor.run(FORWARD);
rightMotor.run(FORWARD);
break;
case 'B':
leftMotor.run(BACKWARD);
rightMotor.run(BACKWARD);
break;
case 'L':
leftMotor.run(BACKWARD);
rightMotor.run(FORWARD);
break;
case 'R':
leftMotor.run(FORWARD);
rightMotor.run(BACKWARD);
break;
case 'S':
leftMotor.run(RELEASE);
rightMotor.run(RELEASE);
break;
case 'P':
for (int i = 0; i < 5; i++) {
digitalWrite(BLUE_LED, HIGH);
delay(200);
digitalWrite(BLUE_LED, LOW);
digitalWrite(RED_LED, HIGH);
delay(200);
digitalWrite(RED_LED, LOW);
}
break;
default:
break;
}
}
}
Arduino UNO Code
#define PIEZO_PIN 7
#define RED_LED_PIN_1 11
#define RED_LED_PIN_2 10
#define BLUE_LED_PIN_1 9
#define BLUE_LED_PIN_2 8
#define POTENTIOMETER_PIN A0
void setup() {
pinMode(PIEZO_PIN, OUTPUT);
pinMode(RED_LED_PIN_1, OUTPUT);
pinMode(RED_LED_PIN_2, OUTPUT);
pinMode(BLUE_LED_PIN_1, OUTPUT);
pinMode(BLUE_LED_PIN_2, OUTPUT);
Serial.begin(9600);
}
void loop() {
runSirenAndLEDs();
}
void runSirenAndLEDs() {
for (int i = 0; i < 350; i++) {
digitalWrite(PIEZO_PIN, HIGH);
digitalWrite(RED_LED_PIN_1, HIGH);
digitalWrite(RED_LED_PIN_2, LOW);
digitalWrite(BLUE_LED_PIN_1, HIGH);
digitalWrite(BLUE_LED_PIN_2, LOW);
delay(1);
digitalWrite(PIEZO_PIN, LOW);
delay(1);
}
delay(50);
for (int i = 0; i < 150; i++) {
digitalWrite(PIEZO_PIN, HIGH);
digitalWrite(RED_LED_PIN_1, LOW);
digitalWrite(RED_LED_PIN_2, HIGH);
digitalWrite(BLUE_LED_PIN_1, LOW);
digitalWrite(BLUE_LED_PIN_2, HIGH);
delay(2);
digitalWrite(PIEZO_PIN, LOW);
delay(2);
}
}
This documentation provides a comprehensive overview of the circuit, including a summary, detailed component list, wiring details, and documented code for the microcontrollers.