I have a circuit where two pumps (currently just LED's) are activated by pressing two different buttons.
After its success, I updated the code to use a bluetooth module HC-05 and control it with an MIT App Inventor app.
Unfortunately, it doesn't work, and I don't know whether the problem lies in the Arduino or the app
The code goes as following:
//Constants pump 1 y 2
const int pin_pumpA = 2;
const int pin_pumpB = 3;
// BT state variable
int bt_state = 0;
void setup()
{
Serial.begin(9600);
pinMode (pin_pumpA, OUTPUT);
pinMode (pin_pumpB, OUTPUT);
}
void loop()
{
//lectura del estado del texto BT
if (Serial.available() > 0)
{
bt_state = Serial.read();
}
if (bt_state == 1)
{
digitalWrite(pin_pumpA,HIGH);
delay(5000);
digitalWrite(pin_pumpA,LOW);
delay(1000);
}
if (bt_state == 2)
{
digitalWrite(pin_pumpB,HIGH);
delay(5000);
digitalWrite(pin_pumpB,LOW);
delay(1000);
}
I could use some help trying to find the problem, thanks!