#include <SoftwareSerial.h>

const int ledPin = 3; // the pin that the LED is attached to
int incomingByte;      // a variable to read incoming serial data info

const int buttonPin =2; //the pin the button is attached to
int buttonState;        //a variable to read incoming serial data info

SoftwareSerial MySerial(0, 1); // RX, TX

void setup() {
  // initialize serial communication:
 MySerial.begin(9600);
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  //initialize the button pin as an input with a pullup resestor
  pinMode(buttonPin, INPUT_PULLUP);
  digitalWrite(buttonPin, HIGH);
  }

void loop() {
  // see if there's incoming serial data:
  if (MySerial.available() > 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = MySerial.read();
    // if it's a capital H (ASCII 72), turn on the LED:
    if (incomingByte == 'H') {
      digitalWrite(ledPin, HIGH);
    }
    // if it's an L (ASCII 76) turn off the LED:
    if (incomingByte == 'L') {
      digitalWrite(ledPin, LOW);  
    }
  }

  //read the state of the button
int button = digitalRead(buttonPin);
  //Check if the button state has changed
  if (button != buttonState) {
  //Make the button state the same as the button
  buttonState=button;
  //If the button state is high button has just been released
  if (buttonState == HIGH)
  //tell the computer the button has been released
    MySerial.print("b");
   //If the button has not been released tell the computer that
    else MySerial.print("B");
  }
  delay(10);
  }