For my performance assignment, I needed to build a car controlled via phone, I built the car but it doesn't work.
Parts I used:
-Arduino Uno
-4 pieces of 6V 250 RPM motor and wheel set.
-HC05 Arduino Bluetooth module.
-L298 DC and stepper motor driver module.
-9v battery.
I tested all the motors with battery and connected them together in parallel.
I connected the 9V battery to the L298 and removed additional cables from there and connected the middle one to the GND pin on the Arduino and the right one to the VIN pin.
I connected the IN1 IN2 IN3 IN4 pins on L298 to the 6th pin, 10th pin, 5th pin and 9th pin on the Arduino respectively.
I connected the VCC GND TXD RXD pins on the HC05 to the 5V pin, GND pin, RX pin (i.e. pin 0) and TX pin (i.e. pin 1) on the Arduino, respectively.
While uploading the code, I removed the RX and tx pins and uploaded the code, then plugged them back in and used 2 applications in order to test the vehicle, their names are:
-Arduino Car (produced by One day of code)
-Bluetooth RC Controller (produced by Andi.Co)
But as a result, the car did not start. I tested the engines and they are working, I connect to the applications but the car does not start.
(sorry for the spelling mistakes, my native language is not english)
const int motorA1 = 5;
const int motorA2 = 6;
const int motorB1 = 10;
const int motorB2 = 9;
int i=0;
int j=0;
int state;
int vSpeed=255;
void setup() {
pinMode(motorA1, OUTPUT);
pinMode(motorA2, OUTPUT);
pinMode(motorB1, OUTPUT);
pinMode(motorB2, OUTPUT);
Serial.begin(9600);
}
void loop() {
// if(digitalRead(BTState)==LOW) { state='S'; }
if(Serial.available() > 0){
state = Serial.read();
}
if (state == '0'){
vSpeed=0;}
else if (state == '1'){
vSpeed=100;}
else if (state == '2'){
vSpeed=180;}
else if (state == '3'){
vSpeed=200;}
else if (state == '4'){
vSpeed=255;}
if (state == 'F') {
analogWrite(motorA1, vSpeed); analogWrite(motorA2, 0);
analogWrite(motorB1, vSpeed); analogWrite(motorB2, 0);
}
else if (state == 'G') {
analogWrite(motorA1,vSpeed ); analogWrite(motorA2, 0);
analogWrite(motorB1, 100); analogWrite(motorB2, 0);
}
else if (state == 'I') {
analogWrite(motorA1, 100); analogWrite(motorA2, 0);
analogWrite(motorB1, vSpeed); analogWrite(motorB2, 0);
}
else if (state == 'B') {
analogWrite(motorA1, 0); analogWrite(motorA2, vSpeed);
analogWrite(motorB1, 0); analogWrite(motorB2, vSpeed);
}
else if (state == 'H') {
analogWrite(motorA1, 0); analogWrite(motorA2, 100);
analogWrite(motorB1, 0); analogWrite(motorB2, vSpeed);
}
else if (state == 'J') {
analogWrite(motorA1, 0); analogWrite(motorA2, vSpeed);
analogWrite(motorB1, 0); analogWrite(motorB2, 100);
}
else if (state == 'L') {
analogWrite(motorA1, vSpeed); analogWrite(motorA2, 150);
analogWrite(motorB1, 0); analogWrite(motorB2, 0);
}
else if (state == 'R') {
analogWrite(motorA1, 0); analogWrite(motorA2, 0);
analogWrite(motorB1, vSpeed); analogWrite(motorB2, 150);
}
else if (state == 'S'){
analogWrite(motorA1, 0); analogWrite(motorA2, 0);
analogWrite(motorB1, 0); analogWrite(motorB2, 0);
}
}