PART A
1a. to change the blinking speed we have two Delay() values to change. Depending on which one we modify we can say how long the light stays on and how long it stays off.
1b. We must add a resistor to make sure we don't overdrive the LED (current or voltage)
2a. ledPin = 13; means the onboard LED would be toggled. I wanted the external LED on pin 9 to light up so... ledPin = 9;
Video:
f-light_bobby_lab2.mp4
Comments (2)
Wendy Ju said
at 2:10 pm on Apr 18, 2011
Can you post photos and/or video of your Frankenlite?
redswood@... said
at 3:24 pm on Apr 23, 2011
Great work!
Nice sketch and photo!
I like that you used a part of the SONY device as a joystick to control the LEDs.
It seems that you forgot to answer some of the questions: 2(b), 3(a), 3(b), and the bonus 3(c).
I know that some of the questions are too simple and maybe boring. It is worth to try some of the the more challenging questions like how to linearize the LED.
This Lab used an 8-bit (from 0 to 255) Pulse-Width Modulation (PWM) to change the duty cycle of an LED, via one of the digital pins (of an Arduino) that support PWM output.
The example code that comes with the Arduino to fade an LED is as follows:
// 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);
}
This code linearly changes the percentage of the duty cycle. However, humans perceive brightness not linearly (but approximately logarithmically) to the percentage of the duty cycle.
To have the LED have a linear fading effect, we can either use a lookup table that has been tested to give a linear perception, or use an exponential function to approximate that lookup table.
You don't have permission to comment on this page.