Introduction: Interactive Cornhole Boards

So here is my attempt at some custom cornhole boards. It was not originally intended to be run off of an arduino or breadboard full of electronics. But, I didn't think Coach Spurrier would resign as head coach for the gamecocks either. So here we are near end of a lackluster Gamecock Football season and im ready to spread some cheer by lighting up the backyard before, during, and after my college football game.

I wanted to light them up with Christmas string lights. Then when we got done painting them my wife said, "It'd be cool if the they flashed". Well, I cant have something this awesome and not what she wanted. I don't know a lot about code or electronics, but I do know how to search instructables for any and all of my questions. I hope that you like the idea. I am entering in the Epilog laser contest. If you like, please vote.

Thanks

Step 1: Why Do I Need Such

With all of the cornhole boards out there I wanted to separate ours with some lights. I also did the mate with Christmas Lights. It is WAY easier and still just as cool. If the RGBs and Arduino aint your thing. Try it

Step 2: Arduino Sketch

Here is my code. There is no code for the switch, I just put a normally open switch from ground to reset. That will cause the code to reset and then start the cascade.

The Spectrum part is straight out of the Arduino Website, I just had to put in all of my inputs

I will move the copied text to the last step. It was in this step but messed up the flow of the ible.

Step 3: Evidently I Have an Amperage Problem

After starting this and committing to the microcontroller, I found that I shouldn't run more that 20 milliamps off of each input. I know that I'll have nine lights on each input. The only reasonable answer is to use a transistor as an amplifier.

Step 4: Transistors to the Rescue!!!!

If you have used transistors before and know what they do, then you know how versatile they are.

I have used them a little, but only as switches. They are used in this project as amplifiers. The actual LED is powered by a separate battery and the signal coming from the arduino goes into the middle leg of the transistor. the base of the transistor is the positive from the battery and the emitter goes to the led. Each circuit on the board is driven by three transistors. Each RGB has Three anodes. One for each anode. The negative for the battery goes to the cathode. I use a 1K ohm resistor from the arduino output to the transitor input. This serves to change the signal to a milliamp sig. There is a current limiting resistor on each leg of the led. It is 220 ohm.

I did a lot of research on the transistor because I only partly remembered using them at school. It wasnt' really my thing at the time. After reading the history of them and the application. They truly are amazing. Check em out.

A transistor is a semiconductor device used to amplify and switch electronic signals and electrical power. It is composed of semiconductor material with at least three terminals for connection to an external circuit. A voltage or current applied to one pair of the transistor's terminals changes the current through another pair of terminals. Because the controlled (output) power can be higher than the controlling (input) power, a transistor can amplify a signal. Today, some transistors are packaged individually, but many more are found embedded in integrated circuits.

Here is a quote from Wikipedia that explains why you should read more!!

The transistor is the fundamental building block of modern electronic devices, and is ubiquitous in modern electronic systems. Following its development in 1947 by American physicists John Bardeen, Walter Brattain, and William Shockley, the transistor revolutionized the field of electronics, and paved the way for smaller and cheaper radios, calculators, and computers, among other things. The transistor is on the list of IEEE milestones in electronics,[1] and the inventors were jointly awarded the 1956 Nobel Prize in Physics for their achievement.[2]

https://en.wikipedia.org/wiki/Transistor

WTF!!!!!

2 billion transistors
While Apple shied away from giving too many technical details about the A8 SoC, it did note that there’s around 2 billion transistors in there, fabricated with a 20nm process. This is a huge step up from the A7 SoC, which had “more than 1 billion transistors” on a 28nm process. While it’s possible that the A7 actually had significantly more than 1 billion transistors, and Apple was just hiding the fact, it seems unlikely. In either case, 2 billion transistors is a huge number for a mobile chip. Intel’s desktop Haswell chips actually have less transistors (~1.4 billion) than the A8

http://www.extremetech.com/computing/189787-apples...

OK. I'm done with the transistor thing. They are an awesome thing. 2,000,0000,000. That is 2,000 millions.

Step 5: Construction of the Boards

I will not go crazy with all of the measurements and the how to's. Here is the ible I used. I would just be plagiarizing

https://www.instructables.com/id/How-to-make-Cornho...

But where mine are different. Lay out all comes from the center of the hole. I laid out a board on the center, then marked out an arc every six inches. Laid out the marks where I thought the lights would look nice.

What did I use for the holes.

I bought a bunch of acrylic circles from hobby lobby. They are 3/4" by 2mill.

I first drilled out my layout with a 1/4" standard bit. Then I used a magnetic press with a forstner bit to drill out my big circles. I set a block under the arm to get a repeatable depth. It was not perfect, but pretty close. I just moved it around to all of my holes that I pre drilled. Before I painted I silicone the acrylic in place. It was just a hair higher than it was supposed to be. I then put painters tape on top of the acrylic. cut it out in shape of the circles and painted. I chose garnet and black for my gamecocks. I think you should as well. Or just don't paint them orange and purple.

Step 6: Setting Up the Lights and Wiring Up

I used weather proof silicone again to set the led's in place. Make sure to know how your layout of the lights go. I bent my ground over. This way I knew the layout of each color.

Then connect the wire to each light. This I did with twist wire nuts. I wanted to solder and shrink wrap but this would have taken me foreverrrrrrrrrrrrrrrrrrrrrrrrr!

I used a 20/5 thermostat wire. It was the only relative thing I had. it also came in pretty handy to keep my lights from crossing.

Then getting them to the breadboard and mounting to underside of the boards

Step 7: What Will I Build With a Epilog Laser

Step 8: Ya Estuvo!!

const int RED4_PIN = 2;
const int GREEN4_PIN = 3;
const int BLUE4_PIN = 4;
const int RED3_PIN = 5;
const int GREEN3_PIN = 6;
const int BLUE3_PIN = 7;
const int RED2_PIN = 8;
const int GREEN2_PIN = 9;
const int BLUE2_PIN = 10;
const int RED1_PIN = 11;
const int GREEN1_PIN = 12;
const int BLUE1_PIN = 13;
const int RED5_PIN = A5;
const int GREEN5_PIN = A4;
const int BLUE5_PIN = A3;
const int RED6_PIN = A2;
const int GREEN6_PIN = A1;
const int BLUE6_PIN = A0;
// This variable controls how fast we loop through the colors.
// (Try changing this to make the fading faster or slower.)
// In milliseconds
void setup()
{

pinMode(RED1_PIN, OUTPUT);
pinMode(GREEN1_PIN, OUTPUT);
pinMode(BLUE1_PIN, OUTPUT);
pinMode(RED2_PIN, OUTPUT);
pinMode(GREEN2_PIN, OUTPUT);
pinMode(BLUE2_PIN, OUTPUT);
pinMode(RED3_PIN, OUTPUT);
pinMode(GREEN3_PIN, OUTPUT);
pinMode(BLUE3_PIN, OUTPUT);
pinMode(RED4_PIN, OUTPUT);
pinMode(GREEN4_PIN, OUTPUT);
pinMode(BLUE4_PIN, OUTPUT);
pinMode(RED5_PIN, OUTPUT);
pinMode(GREEN5_PIN, OUTPUT);
pinMode(BLUE5_PIN, OUTPUT);
pinMode(RED6_PIN, OUTPUT);
pinMode(GREEN6_PIN, OUTPUT);
pinMode(BLUE6_PIN, OUTPUT);

}
void loop(){

mainCascade();
}
// Here we'll configure the Arduino pins we're using to
// drive the LED to be outputs:
void mainCascade()
{
//STEP1
//BLUE
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, LOW);
digitalWrite(BLUE1_PIN, HIGH);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 2
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//BLUE
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, LOW);
digitalWrite(BLUE2_PIN, HIGH);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 3
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//BLUE
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, LOW);
digitalWrite(BLUE3_PIN, HIGH);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 4
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//BLUE
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, LOW);
digitalWrite(BLUE4_PIN, HIGH);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 5
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//BLUE
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, LOW);
digitalWrite(BLUE5_PIN, HIGH);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 6
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, LOW);
digitalWrite(BLUE6_PIN, HIGH);

delay(500);

//STEP 5
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//BLUE
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, LOW);
digitalWrite(BLUE5_PIN, HIGH);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 4
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//BLUE
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, LOW);
digitalWrite(BLUE4_PIN, HIGH);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 3
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//BLUE
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, LOW);
digitalWrite(BLUE3_PIN, HIGH);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 2
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//BLUE
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, LOW);
digitalWrite(BLUE2_PIN, HIGH);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP1
//BLUE
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, LOW);
digitalWrite(BLUE1_PIN, HIGH);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//REPEAT 2 TIMES

//STEP 2
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//BLUE
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, LOW);
digitalWrite(BLUE2_PIN, HIGH);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 3
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//BLUE
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, LOW);
digitalWrite(BLUE3_PIN, HIGH);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 4
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//BLUE
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, LOW);
digitalWrite(BLUE4_PIN, HIGH);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 5
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//BLUE
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, LOW);
digitalWrite(BLUE5_PIN, HIGH);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 6
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, LOW);
digitalWrite(BLUE6_PIN, HIGH);

delay(500);

//STEP 5
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//BLUE
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, LOW);
digitalWrite(BLUE5_PIN, HIGH);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 4
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//BLUE
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, LOW);
digitalWrite(BLUE4_PIN, HIGH);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 3
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//BLUE
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, LOW);
digitalWrite(BLUE3_PIN, HIGH);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 2
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//BLUE
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, LOW);
digitalWrite(BLUE2_PIN, HIGH);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP1
//BLUE
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, LOW);
digitalWrite(BLUE1_PIN, HIGH);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//REPEAT 1 TIME

//STEP 2
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//BLUE
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, LOW);
digitalWrite(BLUE2_PIN, HIGH);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 3
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//BLUE
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, LOW);
digitalWrite(BLUE3_PIN, HIGH);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 4
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//BLUE
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, LOW);
digitalWrite(BLUE4_PIN, HIGH);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 5
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//BLUE
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, LOW);
digitalWrite(BLUE5_PIN, HIGH);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 6
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, LOW);
digitalWrite(BLUE6_PIN, HIGH);

delay(500);

//STEP 5
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//BLUE
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, LOW);
digitalWrite(BLUE5_PIN, HIGH);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 4
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//BLUE
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, LOW);
digitalWrite(BLUE4_PIN, HIGH);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 3
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//BLUE
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, LOW);
digitalWrite(BLUE3_PIN, HIGH);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP 2
//GREEN
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
//BLUE
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, LOW);
digitalWrite(BLUE2_PIN, HIGH);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

//STEP1
//BLUE
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, LOW);
digitalWrite(BLUE1_PIN, HIGH);
//GREEN
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
//GREEN
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
//GREEN
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
//GREEN
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
//GREEN
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);

delay(500);

mainColors();

// The above function turns the individual LEDs full-on and
// full-off. If you want to generate more than eight colors,
// you can do so by varying the brightness of the individual
// LEDs between full-on and full-off.

// The analogWrite() function lets us do this. This function
// lets you dim a LED from full-off to full-on over 255 steps.

// We've written a function called showSpectrum() that smoothly
// steps through all the colors. Again we're just calling it
// here; the actual code is further down in this sketch.
while (true)
{showSpectrum();
}
}
// Here's the mainColors() function we've written.
// This function displays the eight "main" colors that the RGB LED
// can produce. If you'd like to use one of these colors in your
// own sketch, you cancopy and paste that section into your code.
void mainColors()
{
// Off (all LEDs off):
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, LOW);
digitalWrite(BLUE1_PIN, LOW);
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, LOW);
digitalWrite(BLUE2_PIN, LOW);
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, LOW);
digitalWrite(BLUE3_PIN, LOW);
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, LOW);
digitalWrite(BLUE4_PIN, LOW);
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, LOW);
digitalWrite(BLUE5_PIN, LOW);
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, LOW);
digitalWrite(BLUE6_PIN, LOW);
delay(500);
// Red (turn just the red LED on):
digitalWrite(RED1_PIN, HIGH);
digitalWrite(GREEN1_PIN, LOW);
digitalWrite(BLUE1_PIN, LOW);
digitalWrite(RED2_PIN, HIGH);
digitalWrite(GREEN2_PIN, LOW);
digitalWrite(BLUE2_PIN, LOW);
digitalWrite(RED3_PIN, HIGH);
digitalWrite(GREEN3_PIN, LOW);
digitalWrite(BLUE3_PIN, LOW);
digitalWrite(RED4_PIN, HIGH);
digitalWrite(GREEN4_PIN, LOW);
digitalWrite(BLUE4_PIN, LOW);
digitalWrite(RED5_PIN, HIGH);
digitalWrite(GREEN5_PIN, LOW);
digitalWrite(BLUE5_PIN, LOW);
digitalWrite(RED6_PIN, HIGH);
digitalWrite(GREEN6_PIN, LOW);
digitalWrite(BLUE6_PIN, LOW);
delay(500);
// Green (turn just the green LED on):
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);
delay(1000);
// Blue (turn just the blue LED on):
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, LOW);
digitalWrite(BLUE1_PIN, HIGH);
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, LOW);
digitalWrite(BLUE2_PIN, HIGH);
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, LOW);
digitalWrite(BLUE3_PIN, HIGH);
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, LOW);
digitalWrite(BLUE4_PIN, HIGH);
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, LOW);
digitalWrite(BLUE5_PIN, HIGH);
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, LOW);
digitalWrite(BLUE6_PIN, HIGH);
delay(1000);
// Yellow (turn red and green on):
digitalWrite(RED1_PIN, HIGH);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, LOW);
digitalWrite(RED2_PIN, HIGH);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, LOW);
digitalWrite(RED3_PIN, HIGH);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, LOW);
digitalWrite(RED4_PIN, HIGH);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, LOW);
digitalWrite(RED5_PIN, HIGH);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, LOW);
digitalWrite(RED6_PIN, HIGH);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, LOW);
delay(1000);
// Cyan (turn green and blue on):
digitalWrite(RED1_PIN, LOW);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, HIGH);
digitalWrite(RED2_PIN, LOW);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, HIGH);
digitalWrite(RED3_PIN, LOW);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, HIGH);
digitalWrite(RED4_PIN, LOW);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, HIGH);
digitalWrite(RED5_PIN, LOW);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, HIGH);
digitalWrite(RED6_PIN, LOW);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, HIGH);
delay(1000);
// Purple (turn red and blue on):
digitalWrite(RED1_PIN, HIGH);
digitalWrite(GREEN1_PIN, LOW);
digitalWrite(BLUE1_PIN, HIGH);
digitalWrite(RED2_PIN, HIGH);
digitalWrite(GREEN2_PIN, LOW);
digitalWrite(BLUE2_PIN, HIGH);
digitalWrite(RED3_PIN, HIGH);
digitalWrite(GREEN3_PIN, LOW);
digitalWrite(BLUE3_PIN, HIGH);
digitalWrite(RED4_PIN, HIGH);
digitalWrite(GREEN4_PIN, LOW);
digitalWrite(BLUE4_PIN, HIGH);
digitalWrite(RED5_PIN, HIGH);
digitalWrite(GREEN5_PIN, LOW);
digitalWrite(BLUE5_PIN, HIGH);
digitalWrite(RED6_PIN, HIGH);
digitalWrite(GREEN6_PIN, LOW);
digitalWrite(BLUE6_PIN, HIGH);

delay(1000);
// White (turn all the LEDs on):
digitalWrite(RED1_PIN, HIGH);
digitalWrite(GREEN1_PIN, HIGH);
digitalWrite(BLUE1_PIN, HIGH);
digitalWrite(RED2_PIN, HIGH);
digitalWrite(GREEN2_PIN, HIGH);
digitalWrite(BLUE2_PIN, HIGH);
digitalWrite(RED3_PIN, HIGH);
digitalWrite(GREEN3_PIN, HIGH);
digitalWrite(BLUE3_PIN, HIGH);
digitalWrite(RED4_PIN, HIGH);
digitalWrite(GREEN4_PIN, HIGH);
digitalWrite(BLUE4_PIN, HIGH);
digitalWrite(RED5_PIN, HIGH);
digitalWrite(GREEN5_PIN, HIGH);
digitalWrite(BLUE5_PIN, HIGH);
digitalWrite(RED6_PIN, HIGH);
digitalWrite(GREEN6_PIN, HIGH);
digitalWrite(BLUE6_PIN, HIGH);
delay(1000);
}
// Below are two more functions we've written,
// showSpectrum() and showRGB().
// showRGB() displays a single color on the RGB LED.
// You call showRGB() with the number of a color you want
// to display.
// showSpectrum() steps through all the colors of the RGB LED,
// displaying a rainbow. showSpectrum() actually calls showRGB()
// over and over to do this.
// We'll often break tasks down into individual functions like
// this, which makes your sketches easier to follow, and once
// you have a handy function, you can reuse it in your other
// programs.
// showSpectrum()
// This function steps through all the colors of the RGB LED.
// It does this by stepping a variable from 0 to 768 (the total
// number of colors), and repeatedly calling showRGB() to display
// the individual colors.
// In this function, we're using a "for() loop" to step a variable
// from one value to another, and perform a set of instructions
// for each step. For() loops are a very handy way to get numbers
// to count up or down.
// Every for() loop has three statements separated by semicolons:
// 1. Something to do before starting
// 2. A test to perform; as long as it's true,
// it will keep looping
// 3. Something to do after each loop (usually
// increase a variable)
// For the for() loop below, these are the three statements:
// 1. x = 0; Before starting, make x = 0.
// 2. x < 768; While x is less than 768, run the
// following code.
// 3. x++ Putting "++" after a variable means
// "add one to it". (You can also use "x = x + 1")
// Every time you go through the loop, the statements following
// the loop (those within the brackets) will run.
// And when the test in statement 2 is finally false, the sketch
// will continue.
void showSpectrum()
{
int x; // define an integer variable called "x"

// Now we'll use a for() loop to make x count from 0 to 767
// (Note that there's no semicolon after this line!
// That's because the for() loop will repeat the next
// "statement", which in this case is everything within
// the following brackets {} )
for (x = 0; x < 768; x++)
// Each time we loop (with a new value of x), do the following:
{
showRGB(x); // Call RGBspectrum() with our new x
delay(10); // Delay for 10 ms (1/100th of a second)
}
}
// showRGB()
// This function translates a number between 0 and 767 into a
// specific color on the RGB LED. If you have this number count
// through the whole range (0 to 767), the LED will smoothly
// change color through the entire spectrum.
// The "base" numbers are:
// 0 = pure red
// 255 = pure green
// 511 = pure blue
// 767 = pure red (again)
// Numbers between the above colors will create blends. For
// example, 640 is midway between 512 (pure blue) and 767
// (pure red). It will give you a 50/50 mix of blue and red,
// resulting in purple.
// If you count up from 0 to 767 and pass that number to this
// function, the LED will smoothly fade between all the colors.
// (Because it starts and ends on pure red, you can start over
// at 0 without any break in the spectrum).
void showRGB(int color)
{
int redIntensity;
int greenIntensity;
int blueIntensity;
// Here we'll use an "if / else" statement to determine which
// of the three (R,G,B) zones x falls into. Each of these zones
// spans 255 because analogWrite() wants a number from 0 to 255.
// In each of these zones, we'll calculate the brightness
// for each of the red, green, and blue LEDs within the RGB LED.
if (color <= 255) // zone 1
{
redIntensity = 255 - color; // red goes from on to off
greenIntensity = color; // green goes from off to on
blueIntensity = 0; // blue is always off
}
else if (color <= 511) // zone 2
{
redIntensity = 0; // red is always off
greenIntensity = 255 - (color - 256); // green on to off
blueIntensity = (color - 256); // blue off to on
}
else // color >= 512 // zone 3
{
redIntensity = (color - 512); // red off to on
greenIntensity = 0; // green is always off
blueIntensity = 255 - (color - 512); // blue on to off
}
// Now that the brightness values have been set, command the LED
// to those values
analogWrite(RED1_PIN, redIntensity);
analogWrite(BLUE1_PIN, blueIntensity);
analogWrite(GREEN1_PIN, greenIntensity);
analogWrite(RED2_PIN, redIntensity);
analogWrite(BLUE2_PIN, blueIntensity);
analogWrite(GREEN2_PIN, greenIntensity);
analogWrite(RED3_PIN, redIntensity);
analogWrite(BLUE3_PIN, blueIntensity);
analogWrite(GREEN3_PIN, greenIntensity);
analogWrite(RED4_PIN, redIntensity);
analogWrite(BLUE4_PIN, blueIntensity);
analogWrite(GREEN4_PIN, greenIntensity);
analogWrite(RED5_PIN, redIntensity);
analogWrite(BLUE5_PIN, blueIntensity);
analogWrite(GREEN5_PIN, greenIntensity);
analogWrite(RED6_PIN, redIntensity);
analogWrite(BLUE6_PIN, blueIntensity);
analogWrite(GREEN6_PIN, greenIntensity);

}
//while(true)
//{

//}