#include // // constants won't change. They're used here to set pin numbers: const int buttonPin = PA3; // the thnumber of the pushbutton pin const int ledPin = PA7; const int rx = PA1; const int tx = PA0; bool flashing = false; SoftwareSerial mySerial(rx, tx); // variables will change: int buttonState = 0; // variable for reading the pushbutton status void setup() { mySerial.begin(4800); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); } void loop() { // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed. If it is, the buttonState is HIGH: if (buttonState == LOW) { flashing = !flashing; if (flashing) { mySerial.write(1); } delay(1000); } if (flashing ) { if (mySerial.available() > 0) { mySerial.read(); digitalWrite (ledPin, HIGH); delay (1000); digitalWrite (ledPin, LOW); mySerial.write(1); } } }