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.
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?
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.
Hi Tom thanks for responding
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
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.
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);
}