I have a problem , when send 1 or 0 by Bluetooth module the serial monitor print two time (RECEIVED SMS) . what's the wrong ?
This is my code :
char BluetoothData = 0 ;
void setup() {
// initialize serial communication:
Serial.begin(9600);
for (int pin = 1; pin <= 13; pin++)
{
pinMode(pin, OUTPUT); // sets the digitals pin as outputs
digitalWrite(pin, LOW); // sets the digitals pin off defult intial states
}
Serial.println("ALL LEDs NOW OFF \n ");
Serial.println("Please, Enter : ( 1 to Turn on All LEDs ) or ( 0 to Turn off LEDs ) \n");
}
void loop() {
// read the sensor:
if (Serial.available() > 0) {
BluetoothData = Serial.read();
Serial.print("*** RECEIVED SMS *** : ==>> ");
Serial.println(BluetoothData);
if (BluetoothData == '1'){
for (int Pin = 1; Pin <= 13; Pin++) {
digitalWrite(Pin, HIGH);
}
Serial.println("ALL LEDs NOW ON");
}
// turn all the LEDs off:
else if (BluetoothData == '0') {
for (int Pin = 1; Pin <= 13; Pin++) {
digitalWrite(Pin, LOW);
}
Serial.println("ALL LEDs NOW OFF");
}
}
delay(100);
}
This is photo for serial monitor
main()
function, not the necessary#include
statements. So how are we to reproduce the problem?