Homework 04 – Combine Circuits – Olivia Coughlin

5 Nov

int LED = 13;// assign LED variable to pin 13

int button = 7;// set button variable to pin 7

int value = 0;// initialize value variable

int i = 0;// to count up and down

void setup() {

pinMode(LED, OUTPUT);// set LED pin 13 to be used as output

pinMode(button, INPUT);// set button pin 7 to be used as input

}

void loop() { for (i = 0; i < 255; i++) {//fade in

analogWrite(LED, i);// set LED brightness

delay(10);// wait 10ms } for (i = 255; i > 0; i–){// loop from 255 to 1

analogWrite(LED, i);// set brightness

delay(10);// wait 10ms

value = digitalRead(button);// read input on button 7 and store it

if(value == HIGH){// check if input reading on button pin 7 is HIGH

digitalWrite(LED, HIGH);// switches state from 0 to 1 or 1 to 0

} else {

digitalWrite(LED, LOW); }

}

}

http://youtu.be/VxozNwPKegw

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