const int txPin = 1; const int ledPin = 13; const char address = '0'; int ledState = LOW; void setup() { Serial.begin(9600); pinMode(ledPin, OUTPUT); pinMode(txPin, INPUT); } void loop() { if (Serial.available() > 0) { char input = Serial.read(); if (input == address) { // toggle on command ledState = !ledState; // send Ack pinMode(txPin, OUTPUT); Serial.print('a'); pinMode(txPin, INPUT); } } digitalWrite(ledPin, ledState); }