Homework 02- RGB LED Blink with Potentiometer- Charlene Kulesa

29 Oct

I used the Arduino  to create a  sub-loop within the overall loop where the sub-loop increases by one LED each round until all three LEDS are included in the final sub-loop and then the overall loop starts again. The overall delay is controlled by the potentiometer but I created a static hold of .5 seconds after the end of each sub-loop so that there is a visual variance between the sub-loops.

IMG_1613

int red = 3; //setting red led variable  

int blue = 5; //setting blue led variable

int green = 6; //setting green led variable

int pot = 0; //potentiometer

 

void setup() {

pinMode (red, OUTPUT);

pinMode (blue, OUTPUT);

pinMode (green, OUTPUT);

}

void loop() {

  pot = (analogRead(A0));

digitalWrite (red, HIGH); //Turns on the red light

delay(pot); // Delay depending on potentiometer

digitalWrite (red, LOW); //Turns off the red light

delay(500); // Delay of .5 seconds. End of sub-loop 1

digitalWrite (red, HIGH); //Turns on the red light

delay(pot); // Delay depending on potentiometer

digitalWrite (red, LOW); //Turns off the red light

delay(pot); // Delay depending on potentiometer

digitalWrite (blue, HIGH); //Turns on the blue light

delay(pot); // Delay depending on potentiometer

digitalWrite (blue, LOW); //Turns off the blue light

delay(500); //Delay of .5 seconds. End of sub-loop 2

digitalWrite (red, HIGH); //Turns on the red light

delay(pot); //Delay depending on potentiometer

digitalWrite (red, LOW); //Turns off the red light

delay(pot); //Delay depending on potentiometer

digitalWrite (blue, HIGH); //Turns on the blue light

delay(pot); //Delay depending on potentiometer

digitalWrite (blue, LOW); //Turns off the blue light

delay(pot); //Delay depending on potentiometer

digitalWrite (green, HIGH); //Turns on the green light

delay(pot); //Delay depending on potentiometer

digitalWrite (green, LOW); //Turns off the green light

delay(500); //Delay of .5 seconds. End of sub-loop 3

}

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s