#include SoftwareSerial mySerial(0, 1); boolean state = false; void setup() { pinMode(7, OUTPUT); //Set pin as an output mySerial.begin(9600); //Start serial communication @9600 bps } void loop() { if (mySerial.available()) { char val = mySerial.read(); if (val == 't') { if (state == false) { state = true; digitalWrite(7, HIGH); } else { state = false; digitalWrite(7, LOW ); } } } }