#include int sentid = 3; bool serialstop=true; AltSoftSerial mySerial; void setup() { Serial.begin(9600); //communication rate of the Bluetooth module mySerial.begin(9600); } void loop() { mySerial.write(48); Serial.print("4"); while(mySerial.available()==0){ mySerial.print(48); Serial.print("4"); delay(1500); } Serial.println("read"); serialstop=true; while(serialstop){ sentid = mySerial.read(); if (sentid == 1) { Serial.println("1"); } else if (sentid == 2) { Serial.println("2"); } else if (sentid == 3) { serialstop=false; } } Serial.println("write"); delay(5000); }