/* * Bluetooh Basic: LED ON OFF - Avishkar * Coder - Mayoogh Girish * Website - http://bit.do/Avishkar * Download the App : * This program lets you to control a LED on pin 13 of arduino using a bluetooth module */ #include #define txPin 4 // PA0(MISO) transmit signal to the bridge #define rxPin 5 // PA1(SCK) recieves signal from bridge SoftwareSerial mySerial(rxPin,txPin); char Incoming_value = 0; //Variable for storing Incoming_value void setup() { mySerial.begin(9600); //Sets the data rate in bits per second (baud) for serial data transmission pinMode(txPin, INPUT); //default tx as input pinMode(8, OUTPUT); //Sets digital pin 8 as output pin pinMode(4, OUTPUT); //Sets digital pin 4 as output pin } void loop() { if(mySerial.available() > 0) { Incoming_value = mySerial.read(); //Read the incoming data and store it into variable Incoming_value mySerial.print(Incoming_value); //Print Value of Incoming_value in Serial monitor mySerial.print("\n"); //New line if(Incoming_value == '2') //Checks whether value of Incoming_value is equal to 1 { digitalWrite(8, HIGH); //If value is 1 then LED turns ON } else if(Incoming_value == 'B') //Checks whether value of Incoming_value is equal to 0 { digitalWrite(8, LOW); //If value is 0 then LED turns OFF } else if(Incoming_value == '9') //Checks whether value of Incoming_value is equal to 1 { digitalWrite(8, HIGH); //If value is 1 then LED turns ON } else if(Incoming_value == 'I') //Checks whether value of Incoming_value is equal to 0 { digitalWrite(8, LOW); //If value is 0 then LED turns OFF } } }