Jai fait ce code pour commander un palan electrique a distance a laide du app inventor et arduino .. ma seul probleme c est que le module relais ne fonctionne pas bien avec le programme

#include <SoftwareSerial.h>
SoftwareSerial BTserial(0, 1); // RX | TX
// Connect the HC-06 TX to Arduino pin 1 RX.
// Connect the HC-06 RX to Arduino pin 0 TX through a voltage divider.
char B = ’ ';

void setup()
{
// start th serial communication with the host computer
pinMode(13,INPUT); // bouton urg
pinMode(4,OUTPUT); // commande up
pinMode(5,OUTPUT); // commande down
pinMode(6,OUTPUT); // commande left
pinMode(7,OUTPUT); // commande right
pinMode(2, INPUT); // input capteur
pinMode(3, OUTPUT); // output capteur
pinMode(8, INPUT); // input capteur
pinMode(9, OUTPUT); // output capteur
pinMode(10, INPUT); // input capteur
pinMode(12, OUTPUT); // output capteur

Serial.begin(9600);
Serial.println("Arduino with HC-06 is ready");

// start communication with the HC-06 using 9600
BTserial.begin(9600);  
Serial.println("BTserial started at 9600");

}
void loop()
{

 // Keep reading from HC-06 and send to Arduino Serial Monitor
if (BTserial.available())
{  
    B = BTserial.read();
    Serial.write(B);    
}

// Keep reading from Arduino Serial Monitor and send to HC-06
if (Serial.available())
{
    B =  Serial.read();

    // mirror the commands back to the serial monitor
    // makes it easy to follow the commands
    Serial.write(B);   
    BTserial.write(B);  
}

if (B ==‘A’) {
digitalWrite( 4, HIGH);
digitalWrite( 5, LOW);
digitalWrite( 6, LOW);
digitalWrite( 7, LOW);

}
if (B == ‘a’) {
digitalWrite ( 4, LOW);

}
if (B ==‘B’) {
digitalWrite ( 4, LOW);
digitalWrite( 5, HIGH);
digitalWrite( 6, LOW);
digitalWrite( 7, LOW);

}
if (B == ‘b’) {
digitalWrite ( 5, LOW);
}
if (B ==‘C’) {
digitalWrite ( 4, LOW);
digitalWrite( 5, LOW);
digitalWrite( 6, HIGH);
digitalWrite( 7, LOW);

}
if (B == ‘c’) {
digitalWrite ( 6, LOW);
}
if (B ==‘D’) {
digitalWrite ( 4, LOW);
digitalWrite( 5, LOW);
digitalWrite( 6, LOW);
digitalWrite( 7, HIGH);

}
if (B == ‘d’) {
digitalWrite ( 7, LOW);
}
if (B ==‘G’) {
digitalWrite( 4, LOW);
digitalWrite ( 5, LOW);
digitalWrite ( 6, LOW);
digitalWrite ( 7, LOW);

}
if (digitalRead(2) == LOW) {

digitalWrite(3, LOW);
} else {

digitalWrite(3, HIGH);
Serial.print(‘G’);
delay(1000);
digitalWrite(3, LOW);
delay(2000);
}
if (digitalRead(8) == LOW) {

digitalWrite(9, LOW);
} else {

digitalWrite(9, HIGH);
Serial.print(‘G’);
delay(1000);
digitalWrite(9, LOW);
delay(2000);

}
if (digitalRead(10) == LOW) {

digitalWrite(12, LOW);
} else {

digitalWrite(12, HIGH);
Serial.print(‘G’);
delay(1000);
digitalWrite(12, LOW);
delay(2000);

}

if ( B == ‘J’) {
digitalWrite(13,LOW);
}
if ( B ==‘M’) {
digitalWrite(13,HIGH);
}

}

Your topic has been moved here as this forum section is more appropriate than where it was originally posted.

Please take care to post in the correct forum section

The easier you make it to read and copy the code the more likely it is that you will get help

Please follow the advice given in the link below when posting code

I made this code to control an electric hoist remotely using the inventor app and arduino … my only problem is that the relay module does not work well with the program

is the question that the outputs are insufficient to drive the relay module? or is it about the logic of the code?

hello
merci de mettre ton code entre balises

Arduino a utilisé D0 et D1 pour la liaison serie avec le moniteur
tu declares une serialBluetooth avec D0 et D1

tu lances serial begin(9600)
puis serialbluetooth begin (9600)

comme tu les as initialisés dans cet ordre, je suppose que la liaison avec le moniteur ne fonctionne pas
ca donne quoi tes serial.print dans le programme ?

ensuite, pour tes relais, il faut nous donner un lien