Homework 04 – Combine Circuits – Garrett Jensen

5 Nov

I used the servo motor set combined with a led using a simple blink. I set the servo motor to use the fading code we learned to use with an LED in class and combined it with a simple LED blink. I tried to add various third components such as the potentiometer or the motion sensor but was unable to get all three to work together.

My Code:

int ledPin = 9; // LED connected to digital pin 9
int led = 6; // LED connected to digital pin 6

void setup() {
pinMode(led, OUTPUT);
}

void loop() {
// fade in from min to max in increments of 5 points:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}

// fade out from max to min in increments of 5 points:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
digitalWrite(led, HIGH); // turning on LED
delay(1000); // keeping LED on for 1 second
digitalWrite(led, LOW); turning off LED
delay(1000); // keeping LED off for 1 second
}

Leave a comment