Homework 02 – RGB LED blink with Potentiometer – Alex Duden

28 Oct

I created the code to “Hot cross buns”, which can be sped up or slowed down using the potentiometer.

 

ImageImageImageImage

ImageImage

Image

The code:

int red = 3; //setting red led variable
int blue = 5; //setting blue led variable
int green = 6; //setting green led variable
int pot = 0; //setting potentiometer

void setup () {
pinMode(red, OUTPUT);
pinMode(blue, OUTPUT);
pinMode(green, OUTPUT);
}
void loop() {
pot = (analogRead (A0)); //signals to use the potentiometer
digitalWrite (red, HIGH); //turns the red light on “Hot”
delay (pot); //delays using the potentiometer
digitalWrite (red, LOW); //turns the red light off
delay (pot); //delays using the potentiometer
digitalWrite (blue, HIGH); //turns the blue light on “cross”
delay (pot); //delays using the potentiometer
digitalWrite (blue, LOW); //turns the blue light off
delay (pot); //delays using the potentiometer
digitalWrite (green, HIGH); //turns the green light on “buns”
delay (pot); //delays using the potentiometer
digitalWrite (green, LOW); //turns the green light off
delay (pot); //delays using the potentiometer
digitalWrite (red, HIGH); //turns the red light on “Hot”
delay (pot); //delays using the potentiometer
digitalWrite (red, LOW); //turns the red light off
delay (pot); //delays using the potentiometer
digitalWrite (blue, HIGH); //turns the blue light on “cross”
delay (pot); //delays using the potentiometer
digitalWrite (blue, LOW); //turns the blue light off
delay (pot); //delays using the potentiometer
digitalWrite (green, HIGH); //turns the green light on “buns”
delay (pot); //delays using the potentiometer
digitalWrite (green, LOW); //turns the green light off
delay (pot); //delays using the potentiometer
digitalWrite (red, HIGH); //turns the red light on “One ha'”
delay (pot); //delays using the potentiometer
digitalWrite (red, LOW); //turns the red light off
delay (pot); //delays using the potentiometer
digitalWrite (red, HIGH); //turns the red light on “penny”
delay (pot); //delays using the potentiometer
digitalWrite (red, LOW); //turns the red light off
delay (pot); //delays using the potentiometer
digitalWrite (blue, HIGH); //turns the blue light on “Two ha'”
delay (pot); //delays using the potentiometer
digitalWrite (blue, LOW); //turns the blue light off
delay (pot); //delays using the potentiometer
digitalWrite (blue, HIGH); //turns the blue light on “penny”
delay (pot); //delays using the potentiometer
digitalWrite (blue, LOW); //turns the blue light off
delay (pot); //delays using the potentiometer
digitalWrite (red, HIGH); //turns the red light on “Hot”
delay (pot); //delays using the potentiometer
digitalWrite (red, LOW); //turns the red light off
delay (pot); //delays using the potentiometer
digitalWrite (blue, HIGH); //turns the blue light on “cross”
delay (pot); //delays using the potentiometer
digitalWrite (blue, LOW); //turns the blue light off
delay (pot); //delays using the potentiometer
digitalWrite (green, HIGH); //turns the green light on “buns”
delay (pot); //delays using the potentiometer
digitalWrite (green, LOW); //turns the green light off
delay (pot); //delays using the potentiometer
}

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