I am modifying a toy car that has controlling's for all Lamps via Bluetooth . For this I am using a Uno R3 and HC-05 modules. So I wrote below sketch and Its working fine for continuous LED ON mode....
char data = 0;
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT); //Sets pin 13 for the Head / Rear lamps
pinMode(12, OUTPUT); //Sets pin 12 for the Signal Lamps
}
void loop()
{
if (Serial.available() > 0)
{
data = Serial.read(); //Read the incoming data and store it into variable data
Serial.print(data); //Print Value inside data in Serial monitor
Serial.print("\n"); //New line
if (data == 'a') // Checks whether value of data is equal to a
digitalWrite(12, HIGH); //If value is a then Signal turns ON
else if (data == 'b') // Checks whether value of data is equal to 0
digitalWrite(12, LOW); //If value is b then Signal turns OFF
}
else if (Serial.available() > 0)
{
data = Serial.read(); //Read the incoming data and store it into variable data
Serial.print(data); //Print Value inside data in Serial monitor
Serial.print("\n"); //New line
if (data == 'c') // Checks whether value of data is equal to c
digitalWrite(13, HIGH); //If value is c then Head Lamps turns ON
else if (data == 'd') // Checks whether value of data is equal to d
digitalWrite(13, LOW); //If value is d then Head Lamps turns OFF
}
}
The question is , I need PIN -12 LED to blink (Line-18) as Car signal lamps...And I tried several methods to do it and failed...