LOGIN
Murali Mano Joshi
3
Collaborator
Mechanical Engineer
 · RamanathapuramIndia
Share
Report
Get Link
TUTORIAL

Class:3 Color Blink

This code is similar to the first project. But It is a little longer now to create a sequence that will result in seven individual colors. We’ve also replaced the numbers 9, 10, and 11 with the variable names red, green, and blue, and added variables for the timing of the sketch. This will help us to read the code better and understand what exactly is going on.

// const int red = 9;
const int green = 10;
const int blue = 11;
int time = 1000;
int multiple = 2;
void setup() {
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
}
void loop() {
digitalWrite(red, HIGH); // red
delay(time);
digitalWrite(green, HIGH); // yellow
delay(time);
digitalWrite(red, LOW); // green
delay(time);
digitalWrite(blue, HIGH); // cyan
delay(time);
digitalWrite(green, LOW); // blue
delay(time);
digitalWrite(red, HIGH); // magenta
delay(time);
digitalWrite(green, HIGH); // white
delay(time*=multiple);
digitalWrite(blue, LOW); // reset
digitalWrite(green, LOW);
time/=multiple;
} 

The circuit connection also similar to the previous model.

Arduino
2 likes 
Like
Award Contribution
Leave a reply...
DISCOVER
CHAT
HIRE
ACTIVITY
FEED
New Post
Help
Start Project
Online Users
Share Link
Write something before you submit it!
Photo updated
Request Sent!
Updated
Copied to Clipboard