Difference between revisions of "Brooke's LED Fade"

From CHS Sigma
Jump to: navigation, search
(Circuit Diagram:)
(Problems and Solutions:)
Line 14: Line 14:
  
 
==Problems and Solutions:==
 
==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:==
 
==Circuit Diagram:==

Revision as of 16:57, 25 October 2016

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.

Materials:

-1 Arduino -1 breadboard -1 USB cable -1 LED -1 220Ω resistor -2 male-male jumper wires

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);
 
 
}