Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Project Name: Arduino Blink Assignment
- Name: Marquessa MacKenzie
- Date: Sept 17th, 2019
- Project: DIGF 2002 - Physical Computing Week Two Inclass Assignment
- Resources: https://www.arduino.cc/en/tutorial/fading
- https://www.arduino.cc/reference/en/language/functions/digital-io/pinmode/
- https://www.arduino.cc/en/Tutorial/Blink
- */
- void setup() {
- // put your setup code here, to run once:
- pinMode(7, OUTPUT);//Setting 7 to output for blink
- pinMode(2, OUTPUT);//Setting 2 to output for blink
- pinMode(9, OUTPUT);//Setting 9 to output for blink and fade
- }
- void loop() {
- // put your main code here, to run repeatedly:
- digitalWrite(7, HIGH); //This turns the green LED on
- delay(1000); //wait for one second
- digitalWrite(7, LOW); //This turns the green LED off
- delay(1000); //wait for a second
- digitalWrite(7, HIGH); //This turns the green LED on
- delay(500); //wait for half of a second
- digitalWrite(7, LOW); //This turns the green LED off
- delay(500); //wait for half of a second
- digitalWrite(7, HIGH); //This turns the green LED on
- delay(1000); //wait for one second
- digitalWrite(7, LOW); //This turns the green LED off
- delay(1000); //wait for a second
- digitalWrite(2, HIGH); //This turns the white LED on
- delay(666); //wait for two thirds of a second
- digitalWrite(2, LOW); //This turns the white LED off
- delay(333); //wait for a third of a second
- digitalWrite(2, HIGH); //This turns the white LED on
- delay(666); //wait for two thirds second
- digitalWrite(2, LOW); //This turns the white LED off
- delay(333); //wait for one third of a second
- digitalWrite(2, HIGH); //This turns the white LED on
- delay(666); //wait for two thrids of a second
- digitalWrite(2, LOW); //This turns the white LED off
- delay(333); //wait for one third of a second
- digitalWrite(9, HIGH); //This turns the red LED on
- delay(750); //Wait for three quarters of a second
- digitalWrite(9, LOW); //This turns the red LED off
- delay(250); //Wait for a quarter of a second
- digitalWrite(9, HIGH); //This turns the red LED on
- delay(750); //Wait for three quarters of a second
- digitalWrite(9, LOW); //This turns the red LED off
- delay(250); //Wait for a quarter of a second
- digitalWrite(9, HIGH); //This turns the red LED on
- delay(750); //Wait for three quarters of a second
- digitalWrite(9, LOW); //This turns the red LED off
- delay(250); //Wait for a quarter of a second
- //The following code controls the analog fade on the red LED at the end of the sequence:
- //fade in from min to max in increments of 5 points:
- for (int fadeValue = 0 ; fadeValue <= 225; fadeValue += 5)
- {
- //sets the value (range from 0 to 225)
- analogWrite(9, fadeValue);
- //wait for 30 milliseconds to see the dimming effect
- delay(100);
- }
- //fade out from min to max in increments of 5 points:
- for (int fadeValue = 225 ; fadeValue >= 0; fadeValue -= 5)
- {
- //sets the value (range from 0 to 225)
- analogWrite(9, fadeValue);
- //wait for 30 milliseconds to see the dimming effect
- delay(100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement