Introduction: Tilt Activated Cloud Light
I've always been a fan of mood lighting so when I had the option to use neopixels and a sensor I decided I needed my own illuminating cloud. The term cloud is used loosely, since its a wood box with wire and paper spanning across the bottom to construct my imagined cloudscape.
How the light works:
1)The program randomly chooses one of seven preset light patterns when first turned on.
2)When the box is tilted the accelerometer reads values and responds by changing color based on the position of the y-axis.
3)As the box settles and stays in a determined middle range for at least 10 seconds the program randomly chooses from one of the seven patterns.
4)Repeat from #2
Materials List
Electronics:
Arduino Uno
Solder-able Breadboard
Triple Axis Accelerometer
1 m 30 LED Neopixel Strip
2 sets Silicone Clips and Screws
Wall Adapter Power Supply - 5V DC 1A
Electrolytic Decoupling Capacitor 1000uF/25V
Resistor
Hook-up wire - for electronics
velcro - used to attach Arduino Uno to box frame
Box Frame:
Heavy Wire
Tissue paper
Wood screws
Wood glue (optional)
Paint Brush
Wood putty (optional)
Sandpaper
Nails
Wood boards for box frame
Wood strip to run across top (optional)
Ceiling Installation:
Two Washers (1/4" interior hole measurement, 1" outer ring measurement)
Four Eye Bolts - 1/4"
Two nuts
Two Threaded Rods - 1/4" x 12"
Two coupling bolts - 1/4"
Two Toggle Bolts - 1/4"
Two S hooks (large enough for your eye bolts)
Tools:
Handsaw
Drill
Drill bits
Wood clamps
Sanding block
Wire cutters
Pliers
Miter box (if using miter joints)
Wood Chisel (optional)
Wood Rasp (optional)
Corner clamps (optional but very handy)
Arduino Software (free!)
Cerberus USB Cable
Soldering Iron
Solder
Hammer
Wood Mallet (optional)
Step 1: Preparing the wooden box frame
Step 2: Assembling the box
Step 3: Preparing and Attaching the Neopixels
Step 4: Circuit Diagram
Step 5: Attaching the Arduino, accelerometor, and power cord
Step 6: Programming Part 1: Finding sensor values
Step 7: Programming Part 2: Programming light patterns
Step 8: Programming Part 3: Random
Step 9: Programming Part 4: Assembling the program
Step 10: Upload!
Step 11: Attaching wire and paper "cloud" surface
Step 12: Suspending your cloud
How the light works:
1)The program randomly chooses one of seven preset light patterns when first turned on.
2)When the box is tilted the accelerometer reads values and responds by changing color based on the position of the y-axis.
3)As the box settles and stays in a determined middle range for at least 10 seconds the program randomly chooses from one of the seven patterns.
4)Repeat from #2
Materials List
Electronics:
Arduino Uno
Solder-able Breadboard
Triple Axis Accelerometer
1 m 30 LED Neopixel Strip
2 sets Silicone Clips and Screws
Wall Adapter Power Supply - 5V DC 1A
Electrolytic Decoupling Capacitor 1000uF/25V
Resistor
Hook-up wire - for electronics
velcro - used to attach Arduino Uno to box frame
Box Frame:
Heavy Wire
Tissue paper
Wood screws
Wood glue (optional)
Paint Brush
Wood putty (optional)
Sandpaper
Nails
Wood boards for box frame
Wood strip to run across top (optional)
Ceiling Installation:
Two Washers (1/4" interior hole measurement, 1" outer ring measurement)
Four Eye Bolts - 1/4"
Two nuts
Two Threaded Rods - 1/4" x 12"
Two coupling bolts - 1/4"
Two Toggle Bolts - 1/4"
Two S hooks (large enough for your eye bolts)
Tools:
Handsaw
Drill
Drill bits
Wood clamps
Sanding block
Wire cutters
Pliers
Miter box (if using miter joints)
Wood Chisel (optional)
Wood Rasp (optional)
Corner clamps (optional but very handy)
Arduino Software (free!)
Cerberus USB Cable
Soldering Iron
Solder
Hammer
Wood Mallet (optional)
Step 1: Preparing the wooden box frame
Step 2: Assembling the box
Step 3: Preparing and Attaching the Neopixels
Step 4: Circuit Diagram
Step 5: Attaching the Arduino, accelerometor, and power cord
Step 6: Programming Part 1: Finding sensor values
Step 7: Programming Part 2: Programming light patterns
Step 8: Programming Part 3: Random
Step 9: Programming Part 4: Assembling the program
Step 10: Upload!
Step 11: Attaching wire and paper "cloud" surface
Step 12: Suspending your cloud
Step 1: Preparing the Wooden Box Frame
Choose the dimensions of your box frame.
I used a light weight pine board measuring about 1/2" x 4" and decided on a box length at 2 feet and box width at 1 1/2 feet.
In my original design I was going to use a pulley and rope to control the tilt of the box so I cut thinner strips of wood to 1 1/2 feet to run across the top of the box. The strips are not structurally need if you wanted to keep the design minimal. The strip dividing the middle was nice to have for handling the box after the wire and paper were added. It was also a great place to attach the Arduino Uno and accelerometer.
When measuring and cutting multiple pieces of one length, I usually measure, mark, and cut one piece and use the original piece to mark the next.
In total, you need two pieces of wood for the length of the box, and two pieces for the width.
I decided to join the box corners using miter joints so I cut the ends at a 45 degree angle. I had access to a wood shop but a miter joint can easily be cut using a miter box and handsaw. Alternate joining methods can also be used (more information here). A butt joint is easiest.
Before joining the corners of the box, I needed to remove sections across the top for a lap joint. I decided to use a lap joint to attach the strips of wood running across the top because I wanted a clean box profile and structural strength where they were attached. The strip is dividing the length of the board so the measurement I needed was 1 1/2.'
Set the two length boards on edge together and make sure they are even. Measure out the halfway point of the box along the length. Mark the width of the strip by laying it across the top the two boards perpendicular at 90 degrees and divided evenly on the halfway mark. Use a pencil to draw lines tight on either side of the strip onto the two boards. Use the end of the strip and butt it against the side of the boards so the tops are even and aligned with the pencil lines just made. Trace the strip end. Now you have the width and depth that needs to be removed for the strip to sit into the box frame.
Clamp the boards together and saw along the vertical lines until you reach the depth line.
Remove boards and carefully use the wood chisel and wood mallet to remove the remaining tab. I lined the chisel against the horizontal depth line with the flat side facing away from the piece being removed and tapped the end of the chisel with the mallet. (I actually used a medium sized rock for lack of a wood mallet...)
I followed up using a wood rasp to clean up the edges and adjust the size where the cut was too tight. With lap joints it is better to cut slightly inside the line and filing to the line for a good fit.
I used a light weight pine board measuring about 1/2" x 4" and decided on a box length at 2 feet and box width at 1 1/2 feet.
In my original design I was going to use a pulley and rope to control the tilt of the box so I cut thinner strips of wood to 1 1/2 feet to run across the top of the box. The strips are not structurally need if you wanted to keep the design minimal. The strip dividing the middle was nice to have for handling the box after the wire and paper were added. It was also a great place to attach the Arduino Uno and accelerometer.
When measuring and cutting multiple pieces of one length, I usually measure, mark, and cut one piece and use the original piece to mark the next.
In total, you need two pieces of wood for the length of the box, and two pieces for the width.
I decided to join the box corners using miter joints so I cut the ends at a 45 degree angle. I had access to a wood shop but a miter joint can easily be cut using a miter box and handsaw. Alternate joining methods can also be used (more information here). A butt joint is easiest.
Before joining the corners of the box, I needed to remove sections across the top for a lap joint. I decided to use a lap joint to attach the strips of wood running across the top because I wanted a clean box profile and structural strength where they were attached. The strip is dividing the length of the board so the measurement I needed was 1 1/2.'
Set the two length boards on edge together and make sure they are even. Measure out the halfway point of the box along the length. Mark the width of the strip by laying it across the top the two boards perpendicular at 90 degrees and divided evenly on the halfway mark. Use a pencil to draw lines tight on either side of the strip onto the two boards. Use the end of the strip and butt it against the side of the boards so the tops are even and aligned with the pencil lines just made. Trace the strip end. Now you have the width and depth that needs to be removed for the strip to sit into the box frame.
Clamp the boards together and saw along the vertical lines until you reach the depth line.
Remove boards and carefully use the wood chisel and wood mallet to remove the remaining tab. I lined the chisel against the horizontal depth line with the flat side facing away from the piece being removed and tapped the end of the chisel with the mallet. (I actually used a medium sized rock for lack of a wood mallet...)
I followed up using a wood rasp to clean up the edges and adjust the size where the cut was too tight. With lap joints it is better to cut slightly inside the line and filing to the line for a good fit.
Step 2: Assembling the Box
To assemble the box I applied a thin layer of wood glue on each miter cut and used corner clamps to keep the pieces together to dry overnight.
The next day I removed the clamps and predrilled two small holes before using two screws to join the box together on each corner. The wood glue offers additional strength in the joints and also keeps the boards in place as you drill and screw. The box is light enough where you could skip the wood glue if you wanted.
Next, I laid a thin layer of wood glue in the cut areas for the lap joints and set the strips in place. If the fit is close you can use the wood mallet to tap the strip in place. I placed a few heavy boards on top and left the pieces to dry for a few hours. After the wood glue was dry, I predrilled one hole on each side of the strip into the box frame and added a screw.
I drilled two holes on each side of the strip near the box frame for the two eyebolts used to attach the box to the ceiling. Make sure to measure carefully so the holes are at the halfway point on the box. You want the box to be hung at the halfway point so it is balanced on each side and rests level to the ceiling/floor.
To finish the box, fill any gaps with wood putty and sand so it is smooth to the touch. A sanding block works well if you don't have access to power tools.
Attach eyebolts to the wood strip, screwing them in until at least 1/2" of is exposed on the other side of the strip. Secure eyebolts with bolts.
Alternatively, if you omitted the wood strip measure halfway and drill two holes into the top of the box frame.
The next day I removed the clamps and predrilled two small holes before using two screws to join the box together on each corner. The wood glue offers additional strength in the joints and also keeps the boards in place as you drill and screw. The box is light enough where you could skip the wood glue if you wanted.
Next, I laid a thin layer of wood glue in the cut areas for the lap joints and set the strips in place. If the fit is close you can use the wood mallet to tap the strip in place. I placed a few heavy boards on top and left the pieces to dry for a few hours. After the wood glue was dry, I predrilled one hole on each side of the strip into the box frame and added a screw.
I drilled two holes on each side of the strip near the box frame for the two eyebolts used to attach the box to the ceiling. Make sure to measure carefully so the holes are at the halfway point on the box. You want the box to be hung at the halfway point so it is balanced on each side and rests level to the ceiling/floor.
To finish the box, fill any gaps with wood putty and sand so it is smooth to the touch. A sanding block works well if you don't have access to power tools.
Attach eyebolts to the wood strip, screwing them in until at least 1/2" of is exposed on the other side of the strip. Secure eyebolts with bolts.
Alternatively, if you omitted the wood strip measure halfway and drill two holes into the top of the box frame.
Step 3: Preparing and Attaching Neopixels
RGB Neopixel strips are sold by the meter so I bought one meter to cut in half. I left the weatherproof case on and was able to easily cut the strip. I was also delighted at the flexibility of the strip though this project doesn't need flexibility.
Neopixel strips are different from regular LED strips because you can control each LED individually while using a minimal amount of pins on your Arduino Uno.
Cut the Neopixel strip in half along the cut mark on the copper pad between the two middle LEDs. (Photo 2)
Remove the power wire connector (we have some funky power wiring coming up)
Use hook-up wire and solder about 14" of wire to each copper pad. Pay attention or mark each wire or use assigned colors for each pad. There is a pad for power (5v), Data, and ground. Make sure the wires are attached to the end where the arrow is pointing away from the end.
Measure around 1 1/2 ' of hook up wire in each color. Use the wire to attach the two strips together leaving the 1 1/2" to span the width of the box frame. Again, make sure the arrows on the neopixel strips are facing the same direction.
One end of the connected neopixel strips will have no wires attached.
Attach the neopixel strips, using the silicone clips and screws, on the inside of the box. I attached the neopixel strip so the bottom of the strip is around 1/2" from the bottom of the box. I left room below the strip to have space to attach the wire and paper later on. The wood for the box is fairly soft and I was able to use a screw driver without pre-drilling to attach the screws.
Neopixel strips are different from regular LED strips because you can control each LED individually while using a minimal amount of pins on your Arduino Uno.
Cut the Neopixel strip in half along the cut mark on the copper pad between the two middle LEDs. (Photo 2)
Remove the power wire connector (we have some funky power wiring coming up)
Use hook-up wire and solder about 14" of wire to each copper pad. Pay attention or mark each wire or use assigned colors for each pad. There is a pad for power (5v), Data, and ground. Make sure the wires are attached to the end where the arrow is pointing away from the end.
Measure around 1 1/2 ' of hook up wire in each color. Use the wire to attach the two strips together leaving the 1 1/2" to span the width of the box frame. Again, make sure the arrows on the neopixel strips are facing the same direction.
One end of the connected neopixel strips will have no wires attached.
Attach the neopixel strips, using the silicone clips and screws, on the inside of the box. I attached the neopixel strip so the bottom of the strip is around 1/2" from the bottom of the box. I left room below the strip to have space to attach the wire and paper later on. The wood for the box is fairly soft and I was able to use a screw driver without pre-drilling to attach the screws.
Step 4: Circuit Diagram
After ordering all the electronic parts I needed help figuring out how everything should be assembled. Remember how I said the wiring for power would get funky? I had a 5V powered Arduino, a 3.3V Accelerometer, and wanted the Neopixels to be as bright as I could get. I had to get some outside help from knowledgeable friends Tommy and Janell to figure all out. So what is happening in this simplified diagram?
The power cord connects to the breadboard and flows through the capacitor directly to the Neopixel strips. Power is diverted from the breadboard into the Arduino Uno using the 5V pin and 3.3V is connected to the Accelerometer.
It is important to make sure the Arduino is unplugged from the wall socket before connecting it to your computer via USB. You do not want to fry your computer... I also was warned by friend Tommy to unplug the 5V pin (going from the Arduino to the breadboard) when connected to the computer.
Using the breadboard can be avoided by ordering an accelerometer that uses 5V.
The rest of the circuit diagram shows where the data, ground, capacitor, and resistor should be attached. If you are new to how breadboards work, this is a good, simple explanation.
The power cord connects to the breadboard and flows through the capacitor directly to the Neopixel strips. Power is diverted from the breadboard into the Arduino Uno using the 5V pin and 3.3V is connected to the Accelerometer.
It is important to make sure the Arduino is unplugged from the wall socket before connecting it to your computer via USB. You do not want to fry your computer... I also was warned by friend Tommy to unplug the 5V pin (going from the Arduino to the breadboard) when connected to the computer.
Using the breadboard can be avoided by ordering an accelerometer that uses 5V.
The rest of the circuit diagram shows where the data, ground, capacitor, and resistor should be attached. If you are new to how breadboards work, this is a good, simple explanation.
Step 5: Attaching the Arduino, Accelerometor, and Power Cord
When you have the circuit schematics planned out, you are ready to connect everything and attach it to the box.
This soldering how to from howtogeek.com is a good reference if you are new to using a soldering iron.
First, solder the accelerometer to the breadboard according to the circuit diagram and photo. Make sure the accelerometer is as parallel as possible to the breadboard so it reads correctly. Then solder the capacitor, making sure it is connected to the negative and positive correctly.
Next, solder the power, ground, and data wires according to the circuit diagram or photos.
Attach the Arduino Uno and Breadboard to the frame. I used velcro so I could easily remove or change the position of the Arduino Uno if needed. Make sure the Breadboard is as level to the the wood frame as possible so the accelerometer is getting a correct reading.
This soldering how to from howtogeek.com is a good reference if you are new to using a soldering iron.
First, solder the accelerometer to the breadboard according to the circuit diagram and photo. Make sure the accelerometer is as parallel as possible to the breadboard so it reads correctly. Then solder the capacitor, making sure it is connected to the negative and positive correctly.
Next, solder the power, ground, and data wires according to the circuit diagram or photos.
Attach the Arduino Uno and Breadboard to the frame. I used velcro so I could easily remove or change the position of the Arduino Uno if needed. Make sure the Breadboard is as level to the the wood frame as possible so the accelerometer is getting a correct reading.
Step 6: Programming Part 1: Finding Sensor Values
Once I had the wood frame and circuits put together, I took a moment to figure out how my programming would work. I translated my scribbling into a more legible chart for you guys (thanks gliffy.com!)
I realized I needed to find my range of values from the accelerometer in order to figure out the coding.
This is when you'll want to download the Arduino Software.
My friend Tommy helped me with this code:
const int Y_pin = A0;
int accel_y =0;
int min = 336;
int max = 336;
void setup() {
pinMode(Y_pin , INPUT);
Serial.begin(57600);
}
void loop() {
accel_y = analogRead(Y_pin);
if (accel_y >max){
max = accel_y;
}
if (accel_y < min){
min = accel_y;
}
Serial.print("Accel: ");
Serial.print(accel_y);
Serial.print(" min: ");
Serial.print(min);
Serial.print(" max: ");
Serial.println(max);
delay(100);
}
I used the code to find my max and min values using Serial Print (upper righthand corner in Arduino). When I hit serial print, I tilted the box in both directions to the furthest angle I would allow the box to tilt. The helps pinpoint the maximum value and minimum value the accelerometer read.
Save the maximum and minimum numbers to use in Step 9: Programming Part 4: Assembling the Program. The maximum read I recorded was 370 and the minimum was 280.
I realized I needed to find my range of values from the accelerometer in order to figure out the coding.
This is when you'll want to download the Arduino Software.
My friend Tommy helped me with this code:
const int Y_pin = A0;
int accel_y =0;
int min = 336;
int max = 336;
void setup() {
pinMode(Y_pin , INPUT);
Serial.begin(57600);
}
void loop() {
accel_y = analogRead(Y_pin);
if (accel_y >max){
max = accel_y;
}
if (accel_y < min){
min = accel_y;
}
Serial.print("Accel: ");
Serial.print(accel_y);
Serial.print(" min: ");
Serial.print(min);
Serial.print(" max: ");
Serial.println(max);
delay(100);
}
I used the code to find my max and min values using Serial Print (upper righthand corner in Arduino). When I hit serial print, I tilted the box in both directions to the furthest angle I would allow the box to tilt. The helps pinpoint the maximum value and minimum value the accelerometer read.
Save the maximum and minimum numbers to use in Step 9: Programming Part 4: Assembling the Program. The maximum read I recorded was 370 and the minimum was 280.
Step 7: Programming Part 2: Creating Light Patterns
Programming the light patterns was the most fun for me. If you are new to Arduino, their website does an excellent job of explaining basic principles and providing understandable examples of code.
Since my plan is to have my programming use a generator to select one of seven light patterns I decided to write each light pattern as a function.
The following function is actually the tilting pattern going from red to blue. You can also see where I have mapped the accelerometer values and set a constraint:
void color_tilt(){
int accel_value = analogRead(ACCEL_PIN);
accel_value = map(accel_value,MIN_AREAD,MAX_AREAD,0,255);
accel_value = constrain(accel_value,0,255);
for (int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, 255-accel_value,0,accel_value);
strip.show();
delay(2);
}
}
This example should actually be called LighteningAccel and you guessed it! Should look a little like lightening! The color blinks back and forth from white to yellow and back with delays.
void ThunderAccel(){
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,255);
strip.show();
}
delay(200);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay (100);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,0);
strip.show();
}
delay(200);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay(50);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,0);
strip.show();
}
delay(40);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay(20);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,255);
strip.show();
}
delay(200);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay(1000);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,255);
strip.show();
}
delay(200);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay (100);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,0);
strip.show();
}
delay(100);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay(3000);
}
You can find the other patterns, including one brilliant one I borrowed (credit is in the code), in Step 9. Another important note, you'll notice the number 29 comes up a lot. 29 refers to the number of neopixels used in the cloud light. I don't have the full 30 because I burnt the copper away on one of the end neopixels in my first soldering attempt. I simply clipped it off but if you use the full 1 meter Neopixel strip you will want to change the 29 to 30 and adjust a few other light patterns.
Since my plan is to have my programming use a generator to select one of seven light patterns I decided to write each light pattern as a function.
The following function is actually the tilting pattern going from red to blue. You can also see where I have mapped the accelerometer values and set a constraint:
void color_tilt(){
int accel_value = analogRead(ACCEL_PIN);
accel_value = map(accel_value,MIN_AREAD,MAX_AREAD,0,255);
accel_value = constrain(accel_value,0,255);
for (int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, 255-accel_value,0,accel_value);
strip.show();
delay(2);
}
}
This example should actually be called LighteningAccel and you guessed it! Should look a little like lightening! The color blinks back and forth from white to yellow and back with delays.
void ThunderAccel(){
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,255);
strip.show();
}
delay(200);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay (100);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,0);
strip.show();
}
delay(200);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay(50);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,0);
strip.show();
}
delay(40);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay(20);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,255);
strip.show();
}
delay(200);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay(1000);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,255);
strip.show();
}
delay(200);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay (100);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,0);
strip.show();
}
delay(100);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay(3000);
}
You can find the other patterns, including one brilliant one I borrowed (credit is in the code), in Step 9. Another important note, you'll notice the number 29 comes up a lot. 29 refers to the number of neopixels used in the cloud light. I don't have the full 30 because I burnt the copper away on one of the end neopixels in my first soldering attempt. I simply clipped it off but if you use the full 1 meter Neopixel strip you will want to change the 29 to 30 and adjust a few other light patterns.
Step 8: Programming Part 3: Random
At this point, we have our sensor values, our light patterns, and know what actions the program should take, but how do you create a random generator? The answer is you don't! Random() is only pseudo random and uses an algorithm. The patterns will start repeating themselves. So I decided to use RandomSeed, which relies on a floating pin, one with no connections, to provide an arbitrary starting number. The result is still pseudo random, but slightly harder to catch.
The floating pin used in my code is A3.
The floating pin used in my code is A3.
Step 9: Programming Part 4: Assembling the Program
We're almost there!
It is easier for me to explain what is happening in the program by commenting on portions below.
//Beginning of code
#include <Adafruit_NeoPixel.h>
#define PIN 13 //identifies pin 13 connected to the neopixels
const int wait_T = 40;
const int ACCEL_PIN = A0;
const int PixelCount = 29; // I have 29 neopixels
const int MAX_AREAD = 370; // This section establishes the maximum, minimum, median and median window for the program.
const int MIN_AREAD = 280;
const int MID_AREAD = 325;
const int MID_WINDOW = 10;
const int TILT_TIME = 10; // in seconds // the amount of time needed to stay in the window in order to choose a new light pattern
const int Pixel_Start_End = 0; //settings for the random light pattern generator
const boolean UsingBar = false;
int random_pick = 0;
boolean pick_new_random = true;
int accel_read =0;
unsigned long time_keeper = 0;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PixelCount, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(57600);
strip.begin(); // Startup Strip
strip.show(); // Initialize all pixels to 'off'
pinMode(ACCEL_PIN , INPUT); // Configure Accelerometer analog read pin
randomSeed(analogRead(A3));
}
//here is where the action chart is coded:
void loop() {
// Read the accelerometer value
accel_read = analogRead(ACCEL_PIN);
// Pick a new random if it's time to.
if (pick_new_random == true){
random_pick = random(6);
pick_new_random = false;
}
// when the accelerometer value is inside the window it picks from the following functions
if ( (accel_read > MID_AREAD - MID_WINDOW) && (accel_read < MID_AREAD + MID_WINDOW) ){
if (random_pick == 0){
ThunderAccel();
}else if(random_pick == 1){
PatternOne();
}else if(random_pick == 2){
PatternTwo();
}else if(random_pick == 3){
PatternThree();
}else if(random_pick == 4){
PatternFour();
}else if(random_pick == 5){
PatternFive();
}else if(random_pick == 6){
PatternSix();
}
}else{
time_keeper = millis();
while( (millis() - time_keeper) < TILT_TIME * 1000 ){
color_tilt();
}
pick_new_random = true;
}
}
// otherwise the code will do the following tilting pattern
void setStripColor(int RED, int GREEN, int BLUE){
for(int i=0; i<29; i++) {
strip.setPixelColor(i, RED,GREEN,BLUE);
}
strip.show();
}
void color_tilt(){
int accel_value = analogRead(ACCEL_PIN);
accel_value = map(accel_value,MIN_AREAD,MAX_AREAD,0,255);
accel_value = constrain(accel_value,0,255);
for (int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, 255-accel_value,0,accel_value);
strip.show();
delay(2);
}
}
// the following are all the light pattern functions
void PatternOne(){
CylonEyeUp(strip.Color(255,255,255), strip.Color(0,255,255), strip.Color(255,255,255), wait_T, PixelCount, Pixel_Start_End);
delay(wait_T);
//Example: CylonEyeDown(Center_Dot_Color, Second_Dot_color, Third_Dot_color, wait_T, PixelCount, Pixel_Start_End);
CylonEyeDown(strip.Color(255,255,255), strip.Color(0,255,255), strip.Color(255,255,255), wait_T, PixelCount, Pixel_Start_End);
delay(wait_T);
}
void PatternTwo() {
for (int i = 0 ; i<102 ; i++){
setStripColor(i, (204 - i*2) , 204);
delay(20);
}
for (int i = 0 ; i<102 ; i++){
setStripColor(102-i, (i*2) , 204);
delay(20);
}
}
void PatternThree() {
for (int i = 0 ; i<255 ; i++){
setStripColor(255, i , 0);
delay(20);
}
for (int i = 255 ; i>0 ; i--){
setStripColor(255, i , 0);
delay(20);
}
delay(1000);
}
void PatternFour() {
for (int i = 0 ; i<127 ; i++){
setStripColor(255-i*2 , 255-i , 255);
delay(20);
}
for (int i = 0 ; i<127 ; i++){
setStripColor(i*2 , 127+i , 255);
delay(20);
}
delay(2000);
}
void PatternFive(){
strip.setPixelColor(14, 255,255,255);
delay(20);
strip.setPixelColor(15, 255,255,255);
delay(20);
strip.setPixelColor(13, 255,255,255);
delay(20);
strip.setPixelColor(16, 255,255,255);
delay(20);
strip.setPixelColor(12, 255,255,255);
delay(20);
strip.setPixelColor(17, 204,255,255);
delay(20);
strip.setPixelColor(11, 204,255,255);
delay(20);
strip.setPixelColor(18, 204,255,255);
delay(20);
strip.setPixelColor(10, 204,255,255);
delay(20);
strip.setPixelColor(19, 204,255,255);
delay(20);
strip.setPixelColor(9, 204,255,255);
delay(20);
strip.setPixelColor(20, 0,128,255);
delay(20);
strip.setPixelColor(8, 0,128,255);
delay(20);
strip.setPixelColor(21, 0,128,255);
delay(20);
strip.setPixelColor(7, 0,128,255);
delay(20);
strip.setPixelColor(22, 0,128,255);
delay(20);
strip.setPixelColor(6, 0,128,255);
delay(20);
strip.setPixelColor(23, 0,128,255);
delay(20);
strip.setPixelColor(5, 0,128,255);
delay(20);
strip.setPixelColor(24, 0,128,255);
delay(20);
strip.setPixelColor(4, 0,128,255);
delay(20);
strip.setPixelColor(25, 0,128,255);
delay(20);
strip.setPixelColor(3, 0,128,255);
delay(20);
strip.setPixelColor(26, 0,0,255);
delay(20);
strip.setPixelColor(2, 0,0,255);
delay(20);
strip.setPixelColor(27, 0,0,255);
delay(20);
strip.setPixelColor(1, 0,0,255);
delay(20);
strip.setPixelColor(28, 0,0,255);
delay(20);
strip.setPixelColor(0, 0,0,255);
delay(20);
strip.setPixelColor(29, 0,0,255);
delay(20);
strip.show();
}
void PatternSix(){
for (int i=0 ; i<255 ; i=i+1){
strip.setPixelColor(0, 0 , i , 255-i);
strip.setPixelColor(1, 0 , i , 255-i);
strip.setPixelColor(2, 0 , i , 255-i);
strip.setPixelColor(3, 0 , i , 255-i);
strip.setPixelColor(4, 0 , i , 255-i);
strip.setPixelColor(5, 0 , i , 255-i);
strip.setPixelColor(6, 0 , i , 255-i);
strip.setPixelColor(8, 0 , i , 255-i);
strip.setPixelColor(9, 0 , i , 255-i);
strip.setPixelColor(10, 0 , i , 255-i);
strip.setPixelColor(11, 0 , i , 255-i);
strip.setPixelColor(12, 0 , i , 255-i);
strip.setPixelColor(13, 0 , i , 255-i);
strip.setPixelColor(14, 0 , i , 255-i);
strip.setPixelColor(15, 0 , i , 255-i);
strip.setPixelColor(16, 0 , i , 255-i);
strip.setPixelColor(17, 0 , i , 255-i);
strip.setPixelColor(18, 0 , i , 255-i);
strip.setPixelColor(19, 0 , i , 255-i);
strip.setPixelColor(20, 0 , i , 255-i);
strip.setPixelColor(21, 0 , i , 255-i);
strip.setPixelColor(22, 0 , i , 255-i);
strip.setPixelColor(23, 0 , i , 255-i);
strip.setPixelColor(24, 0 , i , 255-i);
strip.setPixelColor(25, 0 , i , 255-i);
strip.setPixelColor(26, 0 , i , 255-i);
strip.setPixelColor(27, 0 , i , 255-i);
strip.setPixelColor(28, 0 , i , 255-i);
strip.setPixelColor(29, 0 , i , 255-i);
delay(10);
strip.show();
}
for (int i=255 ; i>0 ; i=i-1){
strip.setPixelColor(0, 0 , i , 255-i);
strip.setPixelColor(1, 0 , i , 255-i);
strip.setPixelColor(2, 0 , i , 255-i);
strip.setPixelColor(3, 0 , i , 255-i);
strip.setPixelColor(4, 0 , i , 255-i);
strip.setPixelColor(5, 0 , i , 255-i);
strip.setPixelColor(6, 0 , i , 255-i);
strip.setPixelColor(8, 0 , i , 255-i);
strip.setPixelColor(9, 0 , i , 255-i);
strip.setPixelColor(10, 0 , i , 255-i);
strip.setPixelColor(11, 0 , i , 255-i);
strip.setPixelColor(12, 0 , i , 255-i);
strip.setPixelColor(13, 0 , i , 255-i);
strip.setPixelColor(14, 0 , i , 255-i);
strip.setPixelColor(15, 0 , i , 255-i);
strip.setPixelColor(16, 0 , i , 255-i);
strip.setPixelColor(17, 0 , i , 255-i);
strip.setPixelColor(18, 0 , i , 255-i);
strip.setPixelColor(19, 0 , i , 255-i);
strip.setPixelColor(20, 0 , i , 255-i);
strip.setPixelColor(21, 0 , i , 255-i);
strip.setPixelColor(22, 0 , i , 255-i);
strip.setPixelColor(23, 0 , i , 255-i);
strip.setPixelColor(24, 0 , i , 255-i);
strip.setPixelColor(25, 0 , i , 255-i);
strip.setPixelColor(26, 0 , i , 255-i);
strip.setPixelColor(27, 0 , i , 255-i);
strip.setPixelColor(28, 0 , i , 255-i);
strip.setPixelColor(29, 0 , i , 255-i);
delay(10);
strip.show();
}
}
void ThunderAccel(){
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,255);
strip.show();
}
delay(200);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay (100);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,0);
strip.show();
}
delay(200);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay(50);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,0);
strip.show();
}
delay(40);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay(20);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,255);
strip.show();
}
delay(200);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay(1000);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,255);
strip.show();
}
delay(200);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay (100);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,0);
strip.show();
}
delay(100);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay(3000);
}
//Borrowed and Adapted from https://github.com/EternalCore/NeoPixel_Cylon_Scrolling_Eye/blob/master/NeoPixel_Cylon_Eye.ino
void CylonEyeUp(uint32_t Co, uint32_t Ct, uint32_t Ctt, uint8_t Delay, int TotalPixels, int pStart) {
for(int i=pStart; i<TotalPixels; i++) {
if(!UsingBar) { strip.setPixelColor(i+2, Ctt); } //Third Dot Color
strip.setPixelColor(i+1, Ct); //Second Dot Color
strip.setPixelColor(i, Co); //Center Dot Color
strip.setPixelColor(i-1, Ct); //Second Dot Color
if(!UsingBar) { strip.setPixelColor(i-2, Ctt); } //Third Dot Color
if(!UsingBar) {
strip.setPixelColor(i-3, strip.Color(0,0,0)); //Clears the dots after the 3rd color
} else {
strip.setPixelColor(i-2, strip.Color(0,0,0)); //Clears the dots after the 2rd color
}
strip.show();
//Serial.println(i); //Used For pixel Count Debugging
delay(Delay);
}
}
void CylonEyeDown(uint32_t Co, uint32_t Ct, uint32_t Ctt, uint8_t Delay, int TotalPixels, int pEnd) {
for(int i=TotalPixels-1; i>pEnd; i--) {
if(!UsingBar) { strip.setPixelColor(i-2, Ctt); } //Third Dot Color
strip.setPixelColor(i-1, Ct); //Second Dot Color
strip.setPixelColor(i, Co); //Center Dot Color
strip.setPixelColor(i+1, Ct); //Second Dot Color
if(!UsingBar) { strip.setPixelColor(i+2, Ctt); } //Third Dot Color
if(!UsingBar) {
strip.setPixelColor(i+3, strip.Color(0,0,0)); //Clears the dots after the 3rd color
} else {
strip.setPixelColor(i+2, strip.Color(0,0,0)); //Clears the dots after the 2rd color
}
strip.show();
//Serial.println(i); //Used For pixel Count Debugging
delay(Delay);
}
}
It is easier for me to explain what is happening in the program by commenting on portions below.
//Beginning of code
#include <Adafruit_NeoPixel.h>
#define PIN 13 //identifies pin 13 connected to the neopixels
const int wait_T = 40;
const int ACCEL_PIN = A0;
const int PixelCount = 29; // I have 29 neopixels
const int MAX_AREAD = 370; // This section establishes the maximum, minimum, median and median window for the program.
const int MIN_AREAD = 280;
const int MID_AREAD = 325;
const int MID_WINDOW = 10;
const int TILT_TIME = 10; // in seconds // the amount of time needed to stay in the window in order to choose a new light pattern
const int Pixel_Start_End = 0; //settings for the random light pattern generator
const boolean UsingBar = false;
int random_pick = 0;
boolean pick_new_random = true;
int accel_read =0;
unsigned long time_keeper = 0;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PixelCount, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(57600);
strip.begin(); // Startup Strip
strip.show(); // Initialize all pixels to 'off'
pinMode(ACCEL_PIN , INPUT); // Configure Accelerometer analog read pin
randomSeed(analogRead(A3));
}
//here is where the action chart is coded:
void loop() {
// Read the accelerometer value
accel_read = analogRead(ACCEL_PIN);
// Pick a new random if it's time to.
if (pick_new_random == true){
random_pick = random(6);
pick_new_random = false;
}
// when the accelerometer value is inside the window it picks from the following functions
if ( (accel_read > MID_AREAD - MID_WINDOW) && (accel_read < MID_AREAD + MID_WINDOW) ){
if (random_pick == 0){
ThunderAccel();
}else if(random_pick == 1){
PatternOne();
}else if(random_pick == 2){
PatternTwo();
}else if(random_pick == 3){
PatternThree();
}else if(random_pick == 4){
PatternFour();
}else if(random_pick == 5){
PatternFive();
}else if(random_pick == 6){
PatternSix();
}
}else{
time_keeper = millis();
while( (millis() - time_keeper) < TILT_TIME * 1000 ){
color_tilt();
}
pick_new_random = true;
}
}
// otherwise the code will do the following tilting pattern
void setStripColor(int RED, int GREEN, int BLUE){
for(int i=0; i<29; i++) {
strip.setPixelColor(i, RED,GREEN,BLUE);
}
strip.show();
}
void color_tilt(){
int accel_value = analogRead(ACCEL_PIN);
accel_value = map(accel_value,MIN_AREAD,MAX_AREAD,0,255);
accel_value = constrain(accel_value,0,255);
for (int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, 255-accel_value,0,accel_value);
strip.show();
delay(2);
}
}
// the following are all the light pattern functions
void PatternOne(){
CylonEyeUp(strip.Color(255,255,255), strip.Color(0,255,255), strip.Color(255,255,255), wait_T, PixelCount, Pixel_Start_End);
delay(wait_T);
//Example: CylonEyeDown(Center_Dot_Color, Second_Dot_color, Third_Dot_color, wait_T, PixelCount, Pixel_Start_End);
CylonEyeDown(strip.Color(255,255,255), strip.Color(0,255,255), strip.Color(255,255,255), wait_T, PixelCount, Pixel_Start_End);
delay(wait_T);
}
void PatternTwo() {
for (int i = 0 ; i<102 ; i++){
setStripColor(i, (204 - i*2) , 204);
delay(20);
}
for (int i = 0 ; i<102 ; i++){
setStripColor(102-i, (i*2) , 204);
delay(20);
}
}
void PatternThree() {
for (int i = 0 ; i<255 ; i++){
setStripColor(255, i , 0);
delay(20);
}
for (int i = 255 ; i>0 ; i--){
setStripColor(255, i , 0);
delay(20);
}
delay(1000);
}
void PatternFour() {
for (int i = 0 ; i<127 ; i++){
setStripColor(255-i*2 , 255-i , 255);
delay(20);
}
for (int i = 0 ; i<127 ; i++){
setStripColor(i*2 , 127+i , 255);
delay(20);
}
delay(2000);
}
void PatternFive(){
strip.setPixelColor(14, 255,255,255);
delay(20);
strip.setPixelColor(15, 255,255,255);
delay(20);
strip.setPixelColor(13, 255,255,255);
delay(20);
strip.setPixelColor(16, 255,255,255);
delay(20);
strip.setPixelColor(12, 255,255,255);
delay(20);
strip.setPixelColor(17, 204,255,255);
delay(20);
strip.setPixelColor(11, 204,255,255);
delay(20);
strip.setPixelColor(18, 204,255,255);
delay(20);
strip.setPixelColor(10, 204,255,255);
delay(20);
strip.setPixelColor(19, 204,255,255);
delay(20);
strip.setPixelColor(9, 204,255,255);
delay(20);
strip.setPixelColor(20, 0,128,255);
delay(20);
strip.setPixelColor(8, 0,128,255);
delay(20);
strip.setPixelColor(21, 0,128,255);
delay(20);
strip.setPixelColor(7, 0,128,255);
delay(20);
strip.setPixelColor(22, 0,128,255);
delay(20);
strip.setPixelColor(6, 0,128,255);
delay(20);
strip.setPixelColor(23, 0,128,255);
delay(20);
strip.setPixelColor(5, 0,128,255);
delay(20);
strip.setPixelColor(24, 0,128,255);
delay(20);
strip.setPixelColor(4, 0,128,255);
delay(20);
strip.setPixelColor(25, 0,128,255);
delay(20);
strip.setPixelColor(3, 0,128,255);
delay(20);
strip.setPixelColor(26, 0,0,255);
delay(20);
strip.setPixelColor(2, 0,0,255);
delay(20);
strip.setPixelColor(27, 0,0,255);
delay(20);
strip.setPixelColor(1, 0,0,255);
delay(20);
strip.setPixelColor(28, 0,0,255);
delay(20);
strip.setPixelColor(0, 0,0,255);
delay(20);
strip.setPixelColor(29, 0,0,255);
delay(20);
strip.show();
}
void PatternSix(){
for (int i=0 ; i<255 ; i=i+1){
strip.setPixelColor(0, 0 , i , 255-i);
strip.setPixelColor(1, 0 , i , 255-i);
strip.setPixelColor(2, 0 , i , 255-i);
strip.setPixelColor(3, 0 , i , 255-i);
strip.setPixelColor(4, 0 , i , 255-i);
strip.setPixelColor(5, 0 , i , 255-i);
strip.setPixelColor(6, 0 , i , 255-i);
strip.setPixelColor(8, 0 , i , 255-i);
strip.setPixelColor(9, 0 , i , 255-i);
strip.setPixelColor(10, 0 , i , 255-i);
strip.setPixelColor(11, 0 , i , 255-i);
strip.setPixelColor(12, 0 , i , 255-i);
strip.setPixelColor(13, 0 , i , 255-i);
strip.setPixelColor(14, 0 , i , 255-i);
strip.setPixelColor(15, 0 , i , 255-i);
strip.setPixelColor(16, 0 , i , 255-i);
strip.setPixelColor(17, 0 , i , 255-i);
strip.setPixelColor(18, 0 , i , 255-i);
strip.setPixelColor(19, 0 , i , 255-i);
strip.setPixelColor(20, 0 , i , 255-i);
strip.setPixelColor(21, 0 , i , 255-i);
strip.setPixelColor(22, 0 , i , 255-i);
strip.setPixelColor(23, 0 , i , 255-i);
strip.setPixelColor(24, 0 , i , 255-i);
strip.setPixelColor(25, 0 , i , 255-i);
strip.setPixelColor(26, 0 , i , 255-i);
strip.setPixelColor(27, 0 , i , 255-i);
strip.setPixelColor(28, 0 , i , 255-i);
strip.setPixelColor(29, 0 , i , 255-i);
delay(10);
strip.show();
}
for (int i=255 ; i>0 ; i=i-1){
strip.setPixelColor(0, 0 , i , 255-i);
strip.setPixelColor(1, 0 , i , 255-i);
strip.setPixelColor(2, 0 , i , 255-i);
strip.setPixelColor(3, 0 , i , 255-i);
strip.setPixelColor(4, 0 , i , 255-i);
strip.setPixelColor(5, 0 , i , 255-i);
strip.setPixelColor(6, 0 , i , 255-i);
strip.setPixelColor(8, 0 , i , 255-i);
strip.setPixelColor(9, 0 , i , 255-i);
strip.setPixelColor(10, 0 , i , 255-i);
strip.setPixelColor(11, 0 , i , 255-i);
strip.setPixelColor(12, 0 , i , 255-i);
strip.setPixelColor(13, 0 , i , 255-i);
strip.setPixelColor(14, 0 , i , 255-i);
strip.setPixelColor(15, 0 , i , 255-i);
strip.setPixelColor(16, 0 , i , 255-i);
strip.setPixelColor(17, 0 , i , 255-i);
strip.setPixelColor(18, 0 , i , 255-i);
strip.setPixelColor(19, 0 , i , 255-i);
strip.setPixelColor(20, 0 , i , 255-i);
strip.setPixelColor(21, 0 , i , 255-i);
strip.setPixelColor(22, 0 , i , 255-i);
strip.setPixelColor(23, 0 , i , 255-i);
strip.setPixelColor(24, 0 , i , 255-i);
strip.setPixelColor(25, 0 , i , 255-i);
strip.setPixelColor(26, 0 , i , 255-i);
strip.setPixelColor(27, 0 , i , 255-i);
strip.setPixelColor(28, 0 , i , 255-i);
strip.setPixelColor(29, 0 , i , 255-i);
delay(10);
strip.show();
}
}
void ThunderAccel(){
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,255);
strip.show();
}
delay(200);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay (100);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,0);
strip.show();
}
delay(200);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay(50);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,0);
strip.show();
}
delay(40);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay(20);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,255);
strip.show();
}
delay(200);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay(1000);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,255);
strip.show();
}
delay(200);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay (100);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 255,255,0);
strip.show();
}
delay(100);
for(int i=0; i<29; i++) {
strip.setPixelColor(i, 0,0,0);
strip.show();
}
delay(3000);
}
//Borrowed and Adapted from https://github.com/EternalCore/NeoPixel_Cylon_Scrolling_Eye/blob/master/NeoPixel_Cylon_Eye.ino
void CylonEyeUp(uint32_t Co, uint32_t Ct, uint32_t Ctt, uint8_t Delay, int TotalPixels, int pStart) {
for(int i=pStart; i<TotalPixels; i++) {
if(!UsingBar) { strip.setPixelColor(i+2, Ctt); } //Third Dot Color
strip.setPixelColor(i+1, Ct); //Second Dot Color
strip.setPixelColor(i, Co); //Center Dot Color
strip.setPixelColor(i-1, Ct); //Second Dot Color
if(!UsingBar) { strip.setPixelColor(i-2, Ctt); } //Third Dot Color
if(!UsingBar) {
strip.setPixelColor(i-3, strip.Color(0,0,0)); //Clears the dots after the 3rd color
} else {
strip.setPixelColor(i-2, strip.Color(0,0,0)); //Clears the dots after the 2rd color
}
strip.show();
//Serial.println(i); //Used For pixel Count Debugging
delay(Delay);
}
}
void CylonEyeDown(uint32_t Co, uint32_t Ct, uint32_t Ctt, uint8_t Delay, int TotalPixels, int pEnd) {
for(int i=TotalPixels-1; i>pEnd; i--) {
if(!UsingBar) { strip.setPixelColor(i-2, Ctt); } //Third Dot Color
strip.setPixelColor(i-1, Ct); //Second Dot Color
strip.setPixelColor(i, Co); //Center Dot Color
strip.setPixelColor(i+1, Ct); //Second Dot Color
if(!UsingBar) { strip.setPixelColor(i+2, Ctt); } //Third Dot Color
if(!UsingBar) {
strip.setPixelColor(i+3, strip.Color(0,0,0)); //Clears the dots after the 3rd color
} else {
strip.setPixelColor(i+2, strip.Color(0,0,0)); //Clears the dots after the 2rd color
}
strip.show();
//Serial.println(i); //Used For pixel Count Debugging
delay(Delay);
}
}
Step 10: Upload!
Make sure the cloud light is unplugged from the wall, remove 5V wire from pin on Arduino and connect the arduino into your computer. Verify your code by clicking the check mark in the upper right hand corner of the Arduino program. Once it has done compiling, upload the program.
After it has uploaded, disconnect the Arduino from the computer, replace the wire into the 5V pin, and plug it in!
I'm hoping you are being mesmerized by flashing neopixels!
Check to see if tilting interrupts the light pattern and if the lights respond to the tilt. Start wondering how in the world you are supposed to finish and hang this thing?
After it has uploaded, disconnect the Arduino from the computer, replace the wire into the 5V pin, and plug it in!
I'm hoping you are being mesmerized by flashing neopixels!
Check to see if tilting interrupts the light pattern and if the lights respond to the tilt. Start wondering how in the world you are supposed to finish and hang this thing?
Step 11: Attaching Wire and Paper "cloud" Surface
Secure your wires and tape up your delicates! But really, you don't want watered down wood glue dripping all over your electronics.
I saved the wire/paper finish for last. The tissue paper is pretty delicate its a lot easier to solder and connect when the box can lay flat.
The wire is not attached based on a strict pattern or measurement. I marked out intervals along the inside bottom and hit small nails into the frame leaving 1/4" sticking out. I cut wire lengths and wrapped one end to a nail, added a bend, and attached to another nail or onto wire. Repeat until the wire spans across the bottom of the box. I found jewelry pliers were helpful in making loops and squeezing the wire tight where connecting to another wire or nail.
I used cheap tissue paper and wood glue to cover the wire. Cornstarch or white school glue should also work but wood glue is what I had around. Add enough water to some wood glue in a bowl to make it fluid and brushable.
My method was to hold a piece of tissue paper up to a wire section, crease the edges around the wire, and tear/cut loosely to shape. To apply the tissue paper, I brushed wood glue onto the wire and pressed the tissue paper onto the wetted wire so it lightly sticks. I continued to brush on wood glue, folding the edges over the wire or onto a neighboring piece of tissue paper, until the paper is securely attached.
On the edges I found the best method was to brush wood glue along the wood edge, press the paper onto the wood, and leave it a minute to dry slightly. Then I could fold the paper onto the wire frame and apply the glue mixture. Cover the wire and let the paper dry completely.
I saved the wire/paper finish for last. The tissue paper is pretty delicate its a lot easier to solder and connect when the box can lay flat.
The wire is not attached based on a strict pattern or measurement. I marked out intervals along the inside bottom and hit small nails into the frame leaving 1/4" sticking out. I cut wire lengths and wrapped one end to a nail, added a bend, and attached to another nail or onto wire. Repeat until the wire spans across the bottom of the box. I found jewelry pliers were helpful in making loops and squeezing the wire tight where connecting to another wire or nail.
I used cheap tissue paper and wood glue to cover the wire. Cornstarch or white school glue should also work but wood glue is what I had around. Add enough water to some wood glue in a bowl to make it fluid and brushable.
My method was to hold a piece of tissue paper up to a wire section, crease the edges around the wire, and tear/cut loosely to shape. To apply the tissue paper, I brushed wood glue onto the wire and pressed the tissue paper onto the wetted wire so it lightly sticks. I continued to brush on wood glue, folding the edges over the wire or onto a neighboring piece of tissue paper, until the paper is securely attached.
On the edges I found the best method was to brush wood glue along the wood edge, press the paper onto the wood, and leave it a minute to dry slightly. Then I could fold the paper onto the wire frame and apply the glue mixture. Cover the wire and let the paper dry completely.
Step 12: Suspending Your Cloud
Congratulations! Now that you have your own illuminating cloud find the perfect spot to hang it up to enjoy.
I used an eyebolt, a connecting bolt, threaded rod, nut, washer, and toggle bolt as the perfect way to hang up the box. Using a ridged material instead of rope allows the box to tilt but not swing. Assemble the pieces as shown in the photograph.
Find the measurement between the eyebolts on the top of your box. Mark the same distance on the ceiling where you want to install. Double check your measurements before drilling. The toggle bolts need a larger drill bit. The ones I used needed a 3/4" hole.
Once you drill your hole, insert the toggle bolts until they clear the drywall and expand open.
Use the two S hooks to attach the box eyebolts to the ceiling eyebolts.
Plug it in and test it out!
If your balance is off you can always add weight to one side or the other.
I used an eyebolt, a connecting bolt, threaded rod, nut, washer, and toggle bolt as the perfect way to hang up the box. Using a ridged material instead of rope allows the box to tilt but not swing. Assemble the pieces as shown in the photograph.
Find the measurement between the eyebolts on the top of your box. Mark the same distance on the ceiling where you want to install. Double check your measurements before drilling. The toggle bolts need a larger drill bit. The ones I used needed a 3/4" hole.
Once you drill your hole, insert the toggle bolts until they clear the drywall and expand open.
Use the two S hooks to attach the box eyebolts to the ceiling eyebolts.
Plug it in and test it out!
If your balance is off you can always add weight to one side or the other.