Is there anything wrong with this circuit..?

this is my very first circuit i made, im 15 and i made this in fritzing i need a lil guidance

so this is the circuit i made for a bluetooth controlled car which also detects smoke;
are these connections ok? did i make a mistake anywhere?

any help would be appreciated, thank you in advance :slight_smile:

This is the code

int smokeA0=A0;
int buzzer =8;
char t;
float sensorValue;
void setup() {
	pinMode(13,OUTPUT);
	pinMode(12,OUTPUT);
	pinMode(11,OUTPUT);
	pinMode(10,OUTPUT);
  pinMode(buzzer,OUTPUT);
  pinMode(smokeA0,INPUT);
   Serial.begin(9600);
  Serial.println("Gas sensor warming up!");
  delay(6000);
}

void loop() {
  //SMOKE DETECTOR
  sensorValue=analogRead(smokeA0);
  Serial.println(sensorValue);
  delay(2000);
  if(sensorValue > 150)
  {
    Serial.print("Smoke detected!");
    tone(buzzer,1000,200);
  }
  //BLUETOOTH CAR
  if(Serial.available()){
  t = Serial.read();
  Serial.println(t);
}
 
if(t == 'F'){            
  digitalWrite(13,HIGH);
  digitalWrite(11,HIGH);
}
 
else if(t == 'B'){      //move reverse (all  motors rotate in reverse direction)
  digitalWrite(12,HIGH);
  digitalWrite(10,HIGH);
}
  
else if(t == 'L'){      //turn right (left side motors rotate in forward direction,  right side motors doesn't rotate)
  digitalWrite(11,HIGH);
}
 
else  if(t == 'R'){      //turn left (right side motors rotate in forward direction, left  side motors doesn't rotate)
  digitalWrite(13,HIGH);
}
 
else if(t == 'S'){      //STOP (all motors stop)
  digitalWrite(13,LOW);
  digitalWrite(12,LOW);
  digitalWrite(11,LOW);
  digitalWrite(10,LOW);
}
delay(100);
}

Yes. The PP3 battery cannot supply enough current to run the project for more than a few minutes, if that

You need a voltage divider between the TX of the Arduino and the RX of the Bluetooth module to reduce the 5V TX output signal to 3.3V. Not doing so might damage the Bluetooth module.

thank you for responding!! what battery source do you think would be suitable for thiss?

Vin on Arduino is an input, you can't use it to power H-bridge.
it is not clear where you take 5V at all.

yeah i thought so too but i researched a lil and found a circuit when the 5V of the bridge was connected to VIN it seemed to work fine, where do u think it should be connected otherwise?

yeah ill add the voltage divider when i assemble it

on power source of course

btw ive connected the 12v of the h bridge to vcc of the battery and gnd to gnd of the battery is that not enough to power the h bridge

6 AA cells in series would be a good starting point

1 Like

6 AA batteries alrightt, is there anything better i can use?

An appropriate Lipo, but you will need to charge it properly

1 Like

alright i will keep that in mind thank you for the advicee

Hi, @valorantfreak
Welcome to the forum.

Have you got all that hardware?
If so, DON"T connect it all up.

Have you written your code in stages, or is this a main code you have written but not tested?

If it is main untested code, you need to step back some.

Write your code in stages.
Write some code the JUST read the gas detector.
Write some code the JUST communicate with the Bluetooth.
Write some code the JUST to operate the buzzer.
Write some code the JUST to operate the LEDs
Write some code the JUST to control ONE motor.
Write some code the JUST to control more than ONE motor.
When all your codes operate BUG FREE.
Then combine them one at a time, each time getting any bugs out before adding the next.

The idea is to prove you have control and are able to read each peripheral before combining them one code at a time to make your main code.
As you add code bits, any bugs can be found usually in the last added code as you build.

Sorry if it sounds a long laborious process, but it will be quicker than trying to decode a mass of untried functions at once.

To really provide a schematic, please post a copy of your circuit a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Fritzy diagrams do not show the true signal flow or hardware symbols to make your circuit readable.

The two LEDs in series may work on the 3V3 supply, but it is not designed for it and the LEDs really need a current limit resistor.
You need to do some Ohms Law to calculate it.

Do you have a DMM? (Digital MultiMeter}

Tom... :grinning: :+1: :coffee: :australia:

Hi Tom thanks for responding :smiley:
Yes I do have most of the hardware, The motors are broken so I'm guna buy some new ones, and I don't have a power source, I haven't tested the code yet

Fritzing provides a schematic too can we work with that?
I'm sure the LEDs won't last long without resistors and they are not crucial yk, so I'll just remove them, That will reduce the cost and work a little bit and no I don't have a digital multimeter

this is the updated circuit:

and this is the schematic:


the code without LEDs:

int smokeA0=A0;
int buzzer =8;
char t;
float sensorValue;
void setup() {
	pinMode(13,OUTPUT);
	pinMode(12,OUTPUT);
	pinMode(11,OUTPUT);
	pinMode(10,OUTPUT);
  pinMode(buzzer,OUTPUT);
  pinMode(smokeA0,INPUT);
  Serial.begin(9600);
  Serial.println("Gas sensor warming up!");
  delay(6000);
  Serial.printIn("Gas sensor has warmed up!");
}

void loop() {
  //SMOKE DETECTOR
  sensorValue=analogRead(smokeA0);
  Serial.println(sensorValue);
  if(sensorValue > 150)
  {
    Serial.print("Smoke detected!");
    tone(buzzer,1000,200);
  }
  //BLUETOOTH CAR
  if(Serial.available()){
  t = Serial.read();
  Serial.println(t);
}
 
if(t == 'F'){            
  digitalWrite(13,HIGH);
  digitalWrite(11,HIGH);
}
 
else if(t == 'B'){      //move reverse (all  motors rotate in reverse direction)
  digitalWrite(12,HIGH);
  digitalWrite(10,HIGH);
}
  
else if(t == 'L'){      //turn right (left side motors rotate in forward direction,  right side motors doesn't rotate)
  digitalWrite(11,HIGH);
}
 
else  if(t == 'R'){      //turn left (right side motors rotate in forward direction, left  side motors doesn't rotate)
  digitalWrite(13,HIGH);
}
 
else if(t == 'S'){      //STOP (all motors stop)
  digitalWrite(13,LOW);
  digitalWrite(12,LOW);
  digitalWrite(11,LOW);
  digitalWrite(10,LOW);
}
delay(100);
}

Sorry, no, that is even more confusing.
Diagonal crossing wires etc make it unreadable.

Best is to get pen(cil) and paper and hand draw it with all power supplies, labels and pin names.

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

I noticed you connect the 5V output of the Motor Driver to the VIN pin of the UNO. This is the input to the voltage regulator, which you don’t need in this case. Use the 5V pin of the UNO.

1 Like

The HC05 module can be (and is) supplied with 5V, so no voltage dividers needed.

1 Like

From the delay(100) after the ifs I guess you want to check for incoming commands every 0.1 seconds. But at the top of the loop is a delay(2000) that will be executed every time. The delay() function is a blocking function. So you won’t see a new command before 2.1 seconds have passed.

You might want to read Blink Without Delay, this explains the blocking by the delay() function and what to do about it.

By the way: no need to declare A0 as Input, and it might be nice to inform that the warming up period has elapsed.

Hii
This is what i did to the delay, i changed it to 1 sec bcoz 0.1 is just too fast and declaring the A0 just gives more clarity so i just put it there

int smokeA0=A0;
int buzzer =8;
char t;
float sensorValue;
void setup() {
	pinMode(13,OUTPUT);
	pinMode(12,OUTPUT);
	pinMode(11,OUTPUT);
	pinMode(10,OUTPUT);
  pinMode(buzzer,OUTPUT);
  pinMode(smokeA0,INPUT);
  Serial.begin(9600);
  Serial.println("Gas sensor warming up!");
  delay(6000);
  Serial.printIn("Gas sensor has warmed up!");
}

void loop() {
  //SMOKE DETECTOR
  sensorValue=analogRead(smokeA0);
  Serial.println(sensorValue);
  if(sensorValue > 150)
  {
    Serial.print("Smoke detected!");
    tone(buzzer,1000,200);
  }
  //BLUETOOTH CAR
  if(Serial.available()){
  t = Serial.read();
  Serial.println(t);
}
 
if(t == 'F'){            
  digitalWrite(13,HIGH);
  digitalWrite(11,HIGH);
}
 
else if(t == 'B'){      //move reverse (all  motors rotate in reverse direction)
  digitalWrite(12,HIGH);
  digitalWrite(10,HIGH);
}
  
else if(t == 'L'){      //turn right (left side motors rotate in forward direction,  right side motors doesn't rotate)
  digitalWrite(11,HIGH);
}
 
else  if(t == 'R'){      //turn left (right side motors rotate in forward direction, left  side motors doesn't rotate)
  digitalWrite(13,HIGH);
}
 
else if(t == 'S'){      //STOP (all motors stop)
  digitalWrite(13,LOW);
  digitalWrite(12,LOW);
  digitalWrite(11,LOW);
  digitalWrite(10,LOW);
}
delay(1000);
}