Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* blink assignment written by Matthew Borkowski on Septermber 17, 2019
- * Fading code inspired from the Arduino Fading Example by David A. Mellis
- */
- int ledPin = 9;
- void setup() {
- // put your setup code here, to run once:
- pinMode(13, OUTPUT);
- pinMode(12, OUTPUT);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- digitalWrite(13, HIGH); //turns the LEDs on
- digitalWrite(12, HIGH);
- delay(350); // pauses for 350 ms
- digitalWrite(13, LOW);
- delay(200); // pauses for 200 ms
- digitalWrite(12, LOW);
- delay(350);
- // fades in from a minimum of 0 to a maximum of 200 by incriments of 2 points:
- for (int fadeValue = 0; fadeValue <= 200; fadeValue += 2) {
- // sets the value (range from 0 to 200)
- analogWrite(ledPin, fadeValue);
- // wait for 20 milliseconds to see the dimming effect
- delay(20);
- }
- // fades from max of 200 to min of 0 by increments of 2 points
- for (int fadeValue = 200; fadeValue >= 0; fadeValue -= 2) {
- analogWrite(ledPin, fadeValue);
- // wait for 20 milliseconds to see the dimming effect
- delay(20);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement