SoftwareSerial BlueSer(8, 9); // RX, TX
int led=13;
int BluetoothData;
void setup() {
BlueSer.begin(9600);
BlueSer.println("Bluetooth ready, tekan 1 or 0 utk on/off LED");
pinMode(led,OUTPUT);
Serial.begin(9600);
}
void loop() {
if (BlueSer.available()){
BluetoothData=BlueSer.read();
Serial.println(BluetoothData);
if(BluetoothData=='1'){
digitalWrite(led,HIGH);
BlueSer.println("LED on");
}
if (BluetoothData=='0'){
digitalWrite(led,LOW);
BlueSer.println("LED off");
}
}
delay(100);
}