Please refer to my previous blog for the completed circuit for the RGB LED animation. In the previous blog we are showing 3 primary colors( red, green, and blue), but in this project we will show ALL 16 million colors. The program below is the code for showing 16 million colors.
int redPin= 11;
int greenPin= 9;
int bluePin= 10;
void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin,OUTPUT);
}
void loop()
{
for(int red=0; red<255; red++)
{
for( int green=0; green<255; green++)
{
for( int blue=0; blue<255; blue++)
{
analogWrite(redPin,red);
analogWrite(greenPin,green);
analogWrite(bluePin,blue);
delay(1);
}
}
}
}
Obviously, we are not writing all 16 million lines to complete the program. We are using a for loop to write a few lines to show all 16 million colors. In the program above, you can see 3 nested for loops to set a value for 3 different pins.
I think I got it what you are doing here. I would love to see the video like before though. great job Aarav.
LikeLiked by 1 person
I tried to take a video of the RGB LED changing colors, but it is hard to see the colors changing because it goes too fast. It is changing 1000 colors in 1 second. To see all 16 million colors, it will take more than 4 hours.
LikeLike