Difference between revisions of "Brooke's LED Fade"

From CHS Sigma
Jump to: navigation, search
(Problems and Solutions:)
 
Line 4: Line 4:
 
==Process:==
 
==Process:==
 
First, I wired up my circuit using a 220Ω resistor and made the LED blink. Then went to trying to make the LED fade in and out, rather then blink. I then used analogWrite() to make the fading effect.
 
First, I wired up my circuit using a 220Ω resistor and made the LED blink. Then went to trying to make the LED fade in and out, rather then blink. I then used analogWrite() to make the fading effect.
 
==Materials:==
 
-1 Arduino   
 
-1 breadboard 
 
-1 USB cable 
 
-1 LED 
 
-1 220Ω resistor 
 
-2 male-male jumper wires
 
  
 
==Problems and Solutions:==
 
==Problems and Solutions:==

Latest revision as of 10:25, 16 May 2017

Assignment:

Our first assignment was to make a LED fade in and out. This assignment demonstrates the use of analogWrite(). Analogwrite() uses pulse width modulation (PWM) to make the fading effect. The result of the project was a wave of text growing and shrinking the LED brightness.

Process:

First, I wired up my circuit using a 220Ω resistor and made the LED blink. Then went to trying to make the LED fade in and out, rather then blink. I then used analogWrite() to make the fading effect.

Problems and Solutions:

One problem I had was using analogWrite in the code to make the fade. I then solved my problem by researching about analogWrite and how to use correctly in a code. After doing my researching about analogWrite i correctly used it in the code to make the LED fade in and out.

Circuit Diagram:

Ledfade22.png

Code:

    int led = 9;
	int brightness = 0;
	int fadeAmount = 5;
 
	void setup()
{
	pinMode (9, OUTPUT);
}
 
void loop()
{
	analogWrite(led, brightness);
	brightness = brightness + fadeAmount;
    if (brightness <= 0 || brightness >= 255) {
    fadeAmount = -fadeAmount;
    }
    delay(30);
 
 
}