Assignment 3: AnalogWrite

For this circuit: 

  • Red Board & Bread Board
  • 2 LED Lights (Green and Blue) 
  • 5 wires (2 green, 2 blue, 1 white) 
  • 2 resistors (330Ω) 

I have created a fade circuit so that one LED light (green) would increase and decrease its brightness and the other would follow the same motion afterward, except in repeats. 

Here is a demonstration (Although the computer code that I have used is supposed to make the blue on the loop increase and decrease its brightness, it it not working):

Green and Blue lights

Below is the picture of the schematic drawing: 

Below is the coding: 

int BLUE = 5;// Loop
int GREEN = 3;// Set up

void setup() {
// put your setup code here, to run once:
analogWrite (GREEN, 0);
delay (500);
analogWrite (GREEN, 25);
delay (500);
analogWrite (GREEN, 50);
delay (500);
analogWrite (GREEN, 75);
delay (500);
analogWrite (GREEN, 100);
delay (500);
analogWrite (GREEN, 125);
delay (500);
analogWrite (GREEN, 150);
delay (500);
analogWrite (GREEN, 175);
delay (500);
analogWrite (GREEN, 200);
delay (500);
analogWrite (GREEN, 225);
delay (500);
analogWrite (GREEN, 200);
delay (500);
analogWrite (GREEN, 175);
delay (500);
analogWrite (GREEN, 150);
delay (500);
analogWrite (GREEN, 125);
delay (500);
analogWrite (GREEN, 100);
delay (500);
analogWrite (GREEN, 75);
delay (500);
analogWrite (GREEN, 50);
delay (500);
analogWrite (GREEN, 25);
delay (500);
analogWrite (GREEN, 0);
delay (500);
}

void loop() {
// put your main code here, to run repeatedly:
analogWrite (BLUE, 0);
delay (500);
analogWrite (BLUE, 75);
delay (500);
analogWrite (BLUE, 100);
delay (500);
analogWrite (BLUE, 175);
delay (500);
analogWrite (BLUE, 200);
delay (500);
analogWrite (BLUE, 175);
delay (500);
analogWrite (BLUE, 100);
delay (500);
analogWrite (BLUE, 75);
delay (500);
analogWrite (BLUE, 0);
delay (500);
}

Leave a Reply

Your email address will not be published. Required fields are marked *