LED flashing using bluetooth

Hey guys,
I’m trying to make a light-control modul for an airplane.
So I have several outputs with different LED’s.

Now I would like to let output 4 or any other output flashing.
But everything I tried failled…

I hope anyone can help me;-)

My code is attached…thank a lot!!

F-LIGHTER.ino (1.21 KB)

      while (inputString != "b")
        digitalWrite(4, HIGH);
        digitalWrite(4, LOW);

If inputString is not “b” when the while loop is entered then how will it ever leave the loop ?

Thank you for your answer!

Do you have any ideas how to edit the code that it works?
Its one of my first projects and I can't find a solution...

Hope for your help;-)

My iPad refuses to open an .ino file.

Use CTRL T to format your code.
Attach your sketch between code tags, use the </> button.
[code]Paste your sketch here[/code]

You need to describe in detail what the program should do

That's the code I'm using now;-)

But output 4 should be the flashing LED...

The program should set the outputs on and off. I use the app "Arduino Bluetooth" to send the values and the HC-05 bluetooth-module should then set the outputs.

char junk;
String inputString = "";

void setup()                    // run once, when the sketch starts
  Serial.begin(9600);            // set the baud rate to 9600, same should be of your Serial Monitor
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);

void loop()
  if (Serial.available()) {
    while (Serial.available())
      char inChar = (char)Serial.read(); //read the input
      inputString += inChar;        //make a string of the characters coming on serial
    while (Serial.available() > 0)
      junk = Serial.read() ;
    if (inputString == "A") {
      digitalWrite(3, HIGH);
    } else if (inputString == "a") {
      digitalWrite(3, LOW);
    } else if (inputString == "B") {
      while (inputString != "b")
        digitalWrite(4, HIGH);
        digitalWrite(4, LOW);
    } else if (inputString == "C") {
      digitalWrite(5, HIGH);
    } else if (inputString == "c") {
      digitalWrite(5, LOW);
    } else if (inputString == "D") {
      digitalWrite(6, HIGH);
    } else if (inputString == "d") {
      digitalWrite(6, LOW);

    inputString = "";

I'd suggest getting a feeling for doing more than one thing at a time:

As mentioned, once in the while loop, you will be there until 2020+

You must update inputString inside your while loop.

Avoid delay() like you do a plague.

Thank you larryd,
but how can I exit the while loop?

You update inputString by either clearing after a certain number of iterations or by reading another serial string, similar to what you have higher up in the sketch.

Much better to avoid using ‘while’ altogether as it can be blocking to your code.

Stop, take some time and read/understand this discussion:

I really don't know what you mean.
Once startet output 4 with "B" it doesn't stopps flashing.
So, how can I leave this while loop?
Could you write the part of output 4 in code-wise?

Thank's a lot!