char blueToothVal; //Values should be sent using Bluetooth char lastValue; //The last status of the LED (on/off) will be logged in this variable void setup(){ Serial.begin(9600); //Serial Monitor will be started, Baudrate will be 9600 pinMode(8,INPUT); //Pin PD7 will be declared as OUTPUT } void loop(){ if(Serial.available()) //if there are data received... { blueToothVal=Serial.read();//..data should be readed } if (blueToothVal=='1') //if the Bluetooth modul recieves „1“ .. { digitalWrite(13,HIGH); //...red LED should switch on.... if (lastValue!='1') //if the last recieved value was „1“ ... Serial.println(F("LED is on")); //..than show "LED is on" on the Serial Monitor lastValue=blueToothVal; } else if (blueToothVal=='0') //if the Bluetooth Modul recieves „0“... { digitalWrite(13,LOW); //.. LED should not light up if (lastValue!='0') //ir the last received value was „0“ ... Serial.println(F("LED is off")); //... on the Serial Monitor should be displyed „LED is off“ lastValue=blueToothVal; } }