How to write correct sketchup for PWM 3W LED using Power LED driver?

I’m novels for Arduino, and search at Internet, forum, arrived helps from folks, this following sketchup are for using MOSFET to turn LED on/off combined with step down converter (buck).

Before listing, this is a project using as pilot LED for UVA-drone using. First stage in this project was to heavy in weight, so when cut the MOSFET array, cut this step down c., I’m ending up with this PWM LED LED driver (CC 700mA/3W). This circuit are provided with 12 Volt operating.

I think the end could stop with two solutions: 1. make a voltage drop resistor from output in Arduino (the I can use the listing sketchup), or re-write this, as PWM regulator for LED voltage using. I’m not for sure what is best solution?

The LED are two parts, with individual outgoing output from Arduino, pin D10-11-12-D13, where D10-D11 are GREEN LED 3W 3,5 volts, and D12-D13 are RED LED 3WW 2,5 volts. The output are max load 40mA and HIGH=5 volts from Arduino nano(!). About the pattern, GREEN LED flash every 3 sec., and RED LED every 4 sec. Flashtime approx. 95mS, it’s shortness, bu will give strobe effects.

For second solution, this is the sketchup as it is today (not for PWM using):

const int ledPin1 =  13;      // Set's pins in use :
const int ledPin2 =  12;
const int ledPin3 =  11;
const int ledPin4 =  10;

// Variables will change 
int ledState1 = LOW;             
int ledState2 = LOW;
int ledState3 = LOW;             // ledState used to set the :
int ledState4 = LOW;
long previousMillis = 0;        // will store last time LED was updated :
long count = 0;

long interval = 95;           // interval at which to blink (milliseconds) lower faster blinks :

void setup() {
 // set the digital pin as output :

 pinMode(ledPin1, OUTPUT);
 pinMode(ledPin2, OUTPUT);
 pinMode(ledPin3, OUTPUT);
 pinMode(ledPin4, OUTPUT);
}
void loop()
{

 do
 {
   unsigned long currentMillis = millis();

   if (currentMillis - previousMillis > interval) {
     // save the last time you blinked the LED :
     previousMillis = currentMillis;

     // if the LED is off turn it on and vice-versa :
     if (ledState1 == LOW ) {
       ledState1 = HIGH;
       ledState2 = LOW;
     }
     else {
       ledState1 = LOW;
       ledState2 = HIGH;
       count++;
       // set the LED with the ledState of the variable :
     }
     digitalWrite(ledPin1, ledState1);
     digitalWrite(ledPin2, ledState2);
   }
 } while (count < 2); //sets how many blinke :
 ledState2 = LOW;
 digitalWrite(ledPin2, ledState2);
 count = 0;
 //=========================================================
 delay(1000); // PAUSE sets the time beteewn set green and read
 //=========================================================
 do
 {
   unsigned long currentMillis = millis();

   if (currentMillis - previousMillis > interval) {
     // save the last time you blinked the LED :
     previousMillis = currentMillis;

     // if the LED is off turn it on and vice-versa :
     if (ledState3 == LOW) {
       ledState3 = HIGH;
       ledState4 = LOW;
     }
     else {
       ledState3 = LOW;
       ledState4 = HIGH;
       count++;
       // set the LED with the ledState of the variable:
     }
     digitalWrite(ledPin3, ledState3);
     digitalWrite(ledPin4, ledState4);
   }
 } while (count < 2);
 ledState4 = LOW;
 digitalWrite(ledPin4, ledState4);
 count = 0;
 //=========================================================
 delay(1400);  //sets the time between set green and read
 //=========================================================
}

Thanks for help from volunteers!

Please edit your “sketchup” and put in code tags <>.

Also include a schematic.

It is not clear what you need help with. The circuit, the sketch or both?

I can see that your sketch can be greatly improved. Normally millis() is used so that using delay() can be avoided, but your sketch uses both.

Paul

Hi Paul.
What I need help, mainly assistance, more about rewriting of sketchup. From previous code using MOSFET switches as outputs in Arduino, connected to step down voltage regulator / converter, where thinking twice, now I’m use constant current LED driver, 4 pcs. Spare total weight.

I have understood that the time cycle for PWM adjusted using variable resistors (R1-R4 in diagram). But which inputs and outputs pins to use in Arduino? I will see this in a new written sketchup, which is true.

Regarding millis () vs.t overusing delay (), I think this is related to the time differences between the cycle of red LED and green LED, red flashes in its own cycle 4 seconds, and green led 3 seconds. I use words, think, as this has to do with novice for this code language. But the purpose is well to learn, structure, codes and SYNTAXE? Hope I will “get it”, shortly.

If you go to this url http://schematics.com/project/flash-light-arduino-led-driver-281215-1-25356/ you will se the circuit diagram. Hopfull I hope for this give some sense(?). See also attachment, *.ino sketchup file (original).

ENG_ORIGINAL_FLASH_07.11.ino (2.36 KB)

First please do as i ask in my post before. If you cannot understand, please say so.

Puhh, as novels, I begin to understanding why performing code tags :o . This is my code.

``
const int ledPin1 = 13; // Set’s pins in use :
const int ledPin2 = 12;
const int ledPin3 = 11;
const int ledPin4 = 10;

// Variables will change
int ledState1 = LOW;
int ledState2 = LOW;
int ledState3 = LOW; // ledState used to set the :
int ledState4 = LOW;
long previousMillis = 0; // will store last time LED was updated :
long count = 0;

long interval = 95; // interval at which to blink (milliseconds) lower faster blinks :

void setup() {
// set the digital pin as output :

pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
}
void loop()
{

do
{
unsigned long currentMillis = millis();

if (currentMillis - previousMillis > interval) {
// save the last time you blinked the LED :
previousMillis = currentMillis;

// if the LED is off turn it on and vice-versa :
if (ledState1 == LOW ) {
ledState1 = HIGH;
ledState2 = LOW;
}
else {
ledState1 = LOW;
ledState2 = HIGH;
count++;
// set the LED with the ledState of the variable :
}
digitalWrite(ledPin1, ledState1);
digitalWrite(ledPin2, ledState2);
}
} while (count < 2); //sets how many blinke :
ledState2 = LOW;
digitalWrite(ledPin2, ledState2);
count = 0;
//=========================================================
delay(1000); // PAUSE sets the time beteewn set green and read
//=========================================================
do
{
unsigned long currentMillis = millis();

if (currentMillis - previousMillis > interval) {
// save the last time you blinked the LED :
previousMillis = currentMillis;

// if the LED is off turn it on and vice-versa :
if (ledState3 == LOW) {
ledState3 = HIGH;
ledState4 = LOW;
}
else {
ledState3 = LOW;
ledState4 = HIGH;
count++;
// set the LED with the ledState of the variable:
}
digitalWrite(ledPin3, ledState3);
digitalWrite(ledPin4, ledState4);
}
} while (count < 2);
ledState4 = LOW;
digitalWrite(ledPin4, ledState4);
count = 0;
//=========================================================
delay(1400); //sets the time beteewn set green and read
//=========================================================
}


It looks like you need to go and read the instructions, then go back and modify your previous posts (use the "More --> Modify" option to the bottom right of the post) to mark up the code as such so we can review it conveniently and accurately.

Until you reply and demonstrate that you understand these points that have been made so far and can follow instructions, there is absolutely no point working through the other problems with the code, so I will leave it at that for the present.

Well, I made an effort with all my heart, unfortunately unsuccessful, by course (-after that my Google search for reading instruction for why insert code tabs in Sketchup I also read it). I'm still a novice, and when the answer yet as a rookie, I do not know nothing about the instruction execution of code tabs, sorry for not mourning my beginner stage sufficient enough.

OK - let's get past the "code tags" harangue:

  • Type
  • ```*
  • [code]*
  • ```*
    (and Press the ENTER key)
  • Copy and paste your sketch/"code"
  • Type
  • ```*
  • [/code]*
  • ```*
    (and press the ENTER key)
  • Click the Post button
const int ledPin1 =  13;      // Set pin's in use :
const int ledPin2 =  12;
const int ledPin3 =  11;
const int ledPin4 =  10;

// Variables will change :
int ledState1 = LOW;             //
int ledState2 = LOW;
int ledState3 = LOW;             // ledState used to set the LED LED STATUS :
int ledState4 = LOW;
long previousMillis = 0;        // will store last time LED was updated :
long count = 0;

long interval = 95;           // interval at which to blink (milliseconds) lower faster blinks :

void setup() {
  // set the digital pin as output :

  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
}
void loop()
{

  do
  {
    unsigned long currentMillis = millis();

    if (currentMillis - previousMillis > interval) {
      // save the last time you blinked the LED
      previousMillis = currentMillis;

      // if the LED is off turn it on and vice-versa :
      if (ledState1 == LOW ) {
        ledState1 = HIGH;
        ledState2 = LOW;
      }
      else {
        ledState1 = LOW;
        ledState2 = HIGH;
        count++;
        // set the LED with the ledState of the variable :
      }
      digitalWrite(ledPin1, ledState1);
      digitalWrite(ledPin2, ledState2);
    }
  } while (count < 2); //sets how many blinke :
  ledState2 = LOW;
  digitalWrite(ledPin2, ledState2);
  count = 0;
  //=========================================================
  delay(1000); // PAUSE and sets the time beteewen set green and read
  //=========================================================
  do
  {
    unsigned long currentMillis = millis();

    if (currentMillis - previousMillis > interval) {
      // save the last time you blinked the LED
      previousMillis = currentMillis;

      // if the LED is off turn it on and vice-versa:
      if (ledState3 == LOW) {
        ledState3 = HIGH;
        ledState4 = LOW;
      }
      else {
        ledState3 = LOW;
        ledState4 = HIGH;
        count++;
        // set the LED with the ledState of the variable:
      }
      digitalWrite(ledPin3, ledState3);
      digitalWrite(ledPin4, ledState4);
    }
  } while (count < 2);
  ledState4 = LOW;
  digitalWrite(ledPin4, ledState4);
  count = 0;
  //=========================================================
  delay(1400);  //sets the time beteewn set green and read
  //=========================================================
}
[code]

I think I was cleaver to get the

 start / stop in my code, but not sure if everyone understood what I was trying out? 

At least I see that for PWR I have to change sticks. GREEN LED 1 AND 2 is currently pins 13 + 14, changed to 6/8. For RED LED it is exceptionally pins 15 + 16, changed to 9/12. THIS IS ALL pwr, outputs for PWR and sounds best in my case. I am excited to see the changes. Hang on!

My code:

const int ledPin1 =  13;      // Set pin's in use :
const int ledPin2 =  12;
const int ledPin3 =  11;
const int ledPin4 =  10;

// Variables will change :
int ledState1 = LOW;             //
int ledState2 = LOW;
int ledState3 = LOW;             // ledState used to set the LED LED STATUS :
int ledState4 = LOW;
long previousMillis = 0;        // will store last time LED was updated :
long count = 0;

long interval = 95;           // interval at which to blink (milliseconds) lower faster blinks :

void setup() {
  // set the digital pin as output :

  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
}
void loop()
{

  do
  {
    unsigned long currentMillis = millis();

    if (currentMillis - previousMillis > interval) {
      // save the last time you blinked the LED
      previousMillis = currentMillis;

      // if the LED is off turn it on and vice-versa :
      if (ledState1 == LOW ) {
        ledState1 = HIGH;
        ledState2 = LOW;
      }
      else {
        ledState1 = LOW;
        ledState2 = HIGH;
        count++;
        // set the LED with the ledState of the variable :
      }
      digitalWrite(ledPin1, ledState1);
      digitalWrite(ledPin2, ledState2);
    }
  } while (count < 2); //sets how many blinke :
  ledState2 = LOW;
  digitalWrite(ledPin2, ledState2);
  count = 0;
  //=========================================================
  delay(1000); // PAUSE and sets the time beteewen set green and read
  //=========================================================
  do
  {
    unsigned long currentMillis = millis();

    if (currentMillis - previousMillis > interval) {
      // save the last time you blinked the LED
      previousMillis = currentMillis;

      // if the LED is off turn it on and vice-versa:
      if (ledState3 == LOW) {
        ledState3 = HIGH;
        ledState4 = LOW;
      }
      else {
        ledState3 = LOW;
        ledState4 = HIGH;
        count++;
        // set the LED with the ledState of the variable:
      }
      digitalWrite(ledPin3, ledState3);
      digitalWrite(ledPin4, ledState4);
    }
  } while (count < 2);
  ledState4 = LOW;
  digitalWrite(ledPin4, ledState4);
  count = 0;
  //=========================================================
  delay(1400);  //sets the time beteewn set green and read
  //=========================================================
}
const int ledPin1 =  13;      // Set pin's in use :
const int ledPin2 =  12;
const int ledPin3 =  11;
const int ledPin4 =  10;

// Variables will change :
int ledState1 = LOW;             //
int ledState2 = LOW;
int ledState3 = LOW;             // ledState used to set the LED LED STATUS :
int ledState4 = LOW;
long previousMillis = 0;        // will store last time LED was updated :
long count = 0;

long interval = 95;           // interval at which to blink (milliseconds) lower faster blinks :

void setup() {
  // set the digital pin as output :

  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
}
void loop()
{

  do
  {
    unsigned long currentMillis = millis();

    if (currentMillis - previousMillis > interval) {
      // save the last time you blinked the LED
      previousMillis = currentMillis;

      // if the LED is off turn it on and vice-versa :
      if (ledState1 == LOW ) {
        ledState1 = HIGH;
        ledState2 = LOW;
      }
      else {
        ledState1 = LOW;
        ledState2 = HIGH;
        count++;
        // set the LED with the ledState of the variable :
      }
      digitalWrite(ledPin1, ledState1);
      digitalWrite(ledPin2, ledState2);
    }
  } while (count < 2); //sets how many blinke :
  ledState2 = LOW;
  digitalWrite(ledPin2, ledState2);
  count = 0;
  //=========================================================
  delay(1000); // PAUSE and sets the time beteewen set green and read
  //=========================================================
  do
  {
    unsigned long currentMillis = millis();

    if (currentMillis - previousMillis > interval) {
      // save the last time you blinked the LED
      previousMillis = currentMillis;

      // if the LED is off turn it on and vice-versa:
      if (ledState3 == LOW) {
        ledState3 = HIGH;
        ledState4 = LOW;
      }
      else {
        ledState3 = LOW;
        ledState4 = HIGH;
        count++;
        // set the LED with the ledState of the variable:
      }
      digitalWrite(ledPin3, ledState3);
      digitalWrite(ledPin4, ledState4);
    }
  } while (count < 2);
  ledState4 = LOW;
  digitalWrite(ledPin4, ledState4);
  count = 0;
  //=========================================================
  delay(1400);  //sets the time beteewn set green and read
  //=========================================================
}

Well, now you know how to mark it up, please go back and modify your post (use the "More --> Modify" option to the bottom right of the post) to mark up the code in your first two submissions.

This is my last code, but I’m still not comfortable due to the out voltage level produced of this LED drivers(?), nothing to worry about?

const int ledPin1 =  14;      // Set pin's in use :
const int ledPin2 =  13;
const int ledPin3 =  12;
const int ledPin4 =  9;

// Variables will change :
int ledState1 = LOW;             //
int ledState2 = LOW;
int ledState3 = LOW;             // ledState used to set the LED LED STATUS :
int ledState4 = LOW;
long previousMillis = 0;        // will store last time LED was updated :
long count = 0;

long interval = 95;           // interval at which to blink (milliseconds) lower faster blinks :

void setup() {
  // set the digital pin as output :

  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
}
void loop()
{

  do
  {
    unsigned long currentMillis = millis();

    if (currentMillis - previousMillis > interval) {
      // save the last time you blinked the LED
      previousMillis = currentMillis;

      // if the LED is off turn it on and vice-versa :
      if (ledState1 == LOW ) {
        ledState1 = HIGH;
        ledState2 = LOW;
      }
      else {
        ledState1 = LOW;
        ledState2 = HIGH;
        count++;
        // set the LED with the ledState of the variable :
      }
      analogWrite(ledPin1, ledState1); 
      analogWrite(ledPin2, ledState2);
    }
  } while (count < 2); //sets how many blinke :
  ledState2 = LOW;
  analogWrite(ledPin2, ledState2);
  count = 0;
  //=========================================================
  delay(1000); // PAUSE and sets the time beteewen set green and read
  //=========================================================
  do
  {
    unsigned long currentMillis = millis();

    if (currentMillis - previousMillis > interval) {
      // save the last time you blinked the LED
      previousMillis = currentMillis;

      // if the LED is off turn it on and vice-versa:
      if (ledState3 == LOW) {
        ledState3 = HIGH;
        ledState4 = LOW;
      }
      else {
        ledState3 = LOW;
        ledState4 = HIGH;
        count++;
        // set the LED with the ledState of the variable:
      }
      analogWrite(ledPin3, ledState3);
      analogWrite(ledPin4, ledState4);
    }
  } while (count < 2);
  ledState4 = LOW;
  analogWrite(ledPin4, ledState4);
  count = 0;
  //=========================================================
  delay(1400);  //sets the time between set green and red
  //=========================================================
}

Hopefully I get ride of DigitWrite(), all around?

Just a minor point but it is annoying

more about rewriting of sketchup.

It is called a sketch not a sketchup.

Sketchup is a 3D drawing program from Google.

but I'm still not comfortable due to the out voltage level produced of this LED drivers

Can you explain more about this worry as I don't think it is real.

Sory for my mix of contents, no excuse either Sketchup was near to a music group "Chetchup" I was favius of, sketch from now, from humor to the point :).

My worry? PWM has the opportunity for a LED to be dimmed down or up in the brightness. When thinking that voltage at output pin from Arduino is 5 volts, far too high voltage for a LED. With PWM and the numerical value of 0-255, bothe adjusted (brightness control), but also reduce voltage level.

So with changing pulse periods, we can change voltages from Arduino through a device that supports PWM. Yes, I hunt for the solution for a fixed voltage pulse/ strobe to my 3W approximately 3 volt diodes, but are this unit give the correct volts to LED? That is, has always been my question.

Chinese man who sold the unit writes (Goggle transfer to English, I wonder?) "This module is the output current by the conditioning, two Regulate the output voltage, different load, in the same output current, module output voltage is different. By PWM control the size of the output current. "

I think his mention is, dependıng on the load resistance, by provide 700 mA, the out put voltage are correct Adapted to the diode and its correct properties. Using PWM like to adjust current level, never heard before.

Hope this give you an answer to my worry?

This module is the output current by the condition, to regulate the output voltage, different load, in the same output current, module output voltage is different. By PWM control the size of the output current.

With PWM and the numerical value of 0-255, bothe adjusted (brightness control), but also reduce voltage level.

No that is incorrect.
PWM is always a signal of 5V or 0V the output voltage never changes. The brightness only changes because the eye integrates the on / off flashing time into a perceived brightness.
Read this:-
http://www.thebox.myzen.co.uk/Tutorial/PWM.html

You can get a lower voltage out of a PWM wave if you have electronics that integrates the on / off signal to an average level. This circuit is known as a low pass filter.

. When thinking that voltage at output pin from Arduino is 5 volts, far too high voltage for a LED.

That is why there is a resistor in series with the LED, and if there is not one there should be to limit the peak current. This is when an LED is connected directly to an output pin. With an LED driver the role of that resistor is taken over by a transistor.

So with changing pulse periods, we can change voltages from Arduino through a device that supports PWM. Yes,

No.

I hunt for the solution for a fixed voltage pulse/ strobe to my 3W approximately 3 volt diodes, but are this unit give the correct volts to LED?

You are mixing up two different forms of control.
First of all the module monitors the current through the LED and adjusts the voltage across the LED so that the current is at a constant fixed level. This is needed because the voltage needed for a fixed current changes with the individual LED and it's temperature and its age. This is called a constant current circuit.

Then given that control you can reduce the value that the constant current regulates to by another control, this time through a PWM signal that is integrated to be a voltage between 0 and 5V. This voltage is never applied to the LED itself but to the constant current control mechanism. So the maximum current you can apply with the PWM being a steady 5V is the maximum the LED can stand. Any PWM of this control signal will only reduce the current and hence the brightness of the LED.

Therefore you can not produce more voltage than the LED can cope with by using any software.

Grumpy_Mike:
No that is incorrect.
PWM is always a signal of 5V or 0V the output voltage never changes. The brightness only changes because the eye integrates the on / off flashing time into a perceived brightness.
-Well, when I was talking about different voltage level, I was not mention to the output from Arduino, the mention was output from PWM module.

Read this:-
PWM

-Well, done, and read.

You can get a lower voltage out of a PWM wave if you have electronics that integrates the on / off signal to an average level. This circuit is known as a low pass filter.
That is why there is a resistor in series with the LED, and if there is not one there should be to limit the peak current. This is when an LED is connected directly to an output pin. With an LED driver the role of that resistor is taken over by a transistor.
-Well, if you was take a lokk at my schematic diagram, you will discover what model I was using.

No.
You are mixing up two different forms of control.
First of all the module monitors the current through the LED and adjusts the voltage across the LED so that the current is at a constant fixed level. This is needed because the voltage needed for a fixed current changes with the individual LED and it's temperature and its age. This is called a constant current circuit.
-Also, if you see the electronic diagram, you will see the module, a CC.

Then given that control you can reduce the value that the constant current regulates to by another control, this time through a PWM signal that is integrated to be a voltage between 0 and 5V. This voltage is never applied to the LED itself but to the constant current control mechanism. So the maximum current you can apply with the PWM being a steady 5V is the maximum the LED can stand. Any PWM of this control signal will only reduce the current and hence the brightness of the LED.

  • My question was to be sure the voltage (PWMmodule) present for this LED, never past 3,5 V.

Therefore you can not produce more voltage than the LED can cope with by using any software.

  • Se above.

Any way, many thanks overall for good information.

And now (after some uploade problems issue to my Nano, “Bussy com port”, fix with different drive update), the circuit are now fixed mounted, and in work.

  1. But, if I running my Nano, throughout USB 2.0 connection>>PC, the brightness are in some low level brightness. It could have some things to do with bad 3W LED (thanks to cheep=poor LED made in Chine, you get what you pay for…).

  2. The weird thing is, however, that with disconnected USB 2.0, LED provides an extremely fast and constant light = LED is ok. But LED does not blink. In the absence of several LED, temporarily, after search where I saved them of discovering them ?, this has not turned anything with a fact that only an LED connected? Doubtful. I use a voltage source from 2 pieces 18650 batteries, where 7.6 volts is converted to 13.5 volts. Step up voltage converter, max 2A. It is a new chart here
    http://schematics.com/project/23a-flash-light-arduinoled-driver-14012016-2-25831/

From previous diagram (the penultimate ver.), Have replaced some sticks for PWM outputs, now using pin No. 6-9-10-11.

This is my code: (new code for PWM):

const int ledPin1 =  11;      // Set pin's in use :
const int ledPin2 =  10;
const int ledPin3 =  9;
const int ledPin4 =  6;

// Variables will change :
int ledState1 = LOW;             //
int ledState2 = LOW;
int ledState3 = LOW;             // ledState used to set the LED LED STATUS :
int ledState4 = LOW;
long previousMillis = 0;        // will store last time LED was updated :
long count = 0;

long interval = 95;           // interval at which to blink (milliseconds) lower faster blinks :

void setup() {
  // set the digital pin as output :

  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
}
void loop()
{

  do
  {
    unsigned long currentMillis = millis();

    if (currentMillis - previousMillis > interval) {
      // save the last time you blinked the LED
      previousMillis = currentMillis;

      // if the LED is off turn it on and vice-versa :
      if (ledState1 == LOW ) {
        ledState1 = HIGH;
        ledState2 = LOW;
      }
      else {
        ledState1 = LOW;
        ledState2 = HIGH;
        count++;
        // set the LED with the ledState of the variable :
      }
      analogWrite(ledPin1, ledState1); 
      analogWrite(ledPin2, ledState2);
    }
  } while (count < 3); //sets how many blinke :
  ledState2 = LOW;
  analogWrite(ledPin2, ledState2);
  count = 0;
  //=========================================================
  delay(1000); // PAUSE and sets the time beteewen set green and read
  //=========================================================
  do
  {
    unsigned long currentMillis = millis();

    if (currentMillis - previousMillis > interval) {
      // save the last time you blinked the LED
      previousMillis = currentMillis;

      // if the LED is off turn it on and vice-versa:
      if (ledState3 == LOW) {
        ledState3 = HIGH;
        ledState4 = LOW;
      }
      else {
        ledState3 = LOW;
        ledState4 = HIGH;
        count++;
        // set the LED with the ledState of the variable:
      }
      analogWrite(ledPin3, ledState3);
      analogWrite(ledPin4, ledState4);
    }
  } while (count < 2);
  ledState4 = LOW;
  analogWrite(ledPin4, ledState4);
  count = 0;
  //=========================================================
  delay(1400);  //sets the time beteewn set green and read
  //=========================================================
}