/*
* Bluetooh Basic: LED ON OFF - Vishal Nagar
* Coder - Vishal Nagar
* Website - vishalnagarcool.blogspot.com
* Download the App :
* This program lets you to control a LED on pin 13 of arduino using a bluetooth module
*/
char Incoming_value = 0; //Variable for storing Incoming_value
void setup()
{
Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data transmission
pinMode(13, OUTPUT); //Sets digital pin 13 as output pin
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
}
void loop()
{
if(Serial.available() > 0)
{
Incoming_value = Serial.read(); //Read the incoming data and store it into variable Incoming_value
Serial.print(Incoming_value); //Print Value of Incoming_value in Serial monitor
Serial.print("\n"); //New line
if(Incoming_value == 'p') //Checks whether value of Incoming_value is equal to p
digitalWrite(13, HIGH); //If value is P then LED turns ON
digitalWrite(12, LOW); // must be low
digitalWrite(11, LOW); // must be low
digitalWrite(10, LOW); // must be low
else if(Incoming_value == 'q') //Checks whether value of Incoming_value is equal to q
digitalWrite(13, LOW); // must be low
digitalWrite(12, HIGH); //If value is Q then LED turns ON
digitalWrite(11, LOW); // must be low
digitalWrite(10, LOW); // must be low
else if(Incoming_value == 'r') //Checks whether value of Incoming_value is equal to r
digitalWrite(13, LOW); //must be low
digitalWrite(12, LOW); //must be low
digitalWrite(11, HIGH); // If value is R then LED turns ON
digitalWrite(10, LOW); // must be low
else if(Incoming_value == 's') //Checks whether value of Incoming_value is equal to s
digitalWrite(13, LOW); //must be low
digitalWrite(12, LOW); //must be low
digitalWrite(11, LOW); // must be low
digitalWrite(10, HIGH); // If value is S then LED turns ON
}
}
कोई टिप्पणी नहीं:
एक टिप्पणी भेजें