RSS
 

Archive for the ‘arduino’ Category

Arduino Powered Arc Reactor Part 1/2

18 Nov

After receiving my Arduino UNO and playing with it for a bit I realized I needed to pick a project with a goal if I really wanted to learn how to use it. Playing around with tutorials online is fun and all but I find trying to complete a project forces me to learn and retain a lot more information.

So after learning how to make LEDs blink, photocells collect data and piezo speakers buzz (thanks Adafruit!) I set my sights on a project with a due date one month in the future. Completion date? Halloween 2010.

Enter the Arc Reactor.

This seemed like a pretty reasonable project for an Arduino newbie considering it’s really just some glowing LEDs under a shirt. Plus who doesn’t like Iron Man?

So here’s my supply list…

Supplies:

    Arduino Duemilanove (I didn’t know how hot gluing would work and didn’t want to sacrifice my UNO)
    7 5mm White LEDS
    Rectangular PCB large enough to cut into a 4 inch circle
    Hook up wire
    Length of 8 conductor wire (I used an old serial cable)
    InstaMorph Moldable Plastic
    Bread board
    Resistors (150 ohm seemed to work OK)
    Altoid tins for battery pack/arduino holder
    Hot glue
    9v battery + battery hookups
    Gold craft wire
    t-shirt with an internal pocket


After collecting everything I needed for the build I started working out the Arduino code. This could have been accomplished without the Arduino and static lighting but it’s so much cooler with animated LEDs!

The idea was to mount 6 LEDs in a ring shape around a PCB with one LED in the center. The animation sequence I came up with looks like this.

    10 Scrolling LEDs (outer 6 only)
    20 All 7 on (for 60 seconds)
    30 Pulsing LEDs (outer 6 only)
    40 All 7 on (for 60 seconds)
    50 GOTO 10


I used the pulse with modulation (PWM) digital outputs on the Arduino to control the pulsing animation. There are only 6 outputs that support PWM so only the outer ring of LEDs pulse. Here’s a quick test video of the scrolling animation (note: I didn’t have any resistors after the LEDs. I don’t recommend this, despite what some websites say my Arduino was red hot after a few minutes).

The physical build of the Arc Reactor will be in a follow up post. I’ve included the code I used to animate the LEDs below. I’m sure this could have been done in a much more elegant way but I’m new to Arduino programming and it worked.

/*
Tony Stark
Built this in a cave, with a box of scraps
TheNewHobbyist 2010
http://www.thenewhobbyist.com
*/
// Initialize Variables
int blinkCycle = 0;
int newLed[7] = {3, 5, 6, 9, 10, 11};
int i;
int fadeCycle = 0;
void setup() {         
// Nothing needed, config mode? blink all LEDs?
}
void loop() { 
if (blinkCycle == 6) { // Skip blink if t's already run 6 times
goto fade;
}
for (i = 0; i < 6; i = i + 1)  {
// Blink array in order
analogWrite(newLed[i], 255);
delay(200); // change for slower blinking
analogWrite(newLed[i], 0);
}
if (i == 6) // If finished array...
{
i = 0; // start over
blinkCycle++; // count times through loop
if (blinkCycle == 6) { // blinked x times already, LIGHT IT UP
analogWrite(newLed[0], 255);
analogWrite(newLed[1], 255);  
analogWrite(newLed[2], 255);
analogWrite(newLed[3], 255);  
analogWrite(newLed[4], 255);  
analogWrite(newLed[5], 255);    
delay (60000); // wait between animations
}
}
fade:
if (blinkCycle == 6) { 
Serial.println("DONE");
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {  // fade in
analogWrite(newLed[0], fadeValue);
analogWrite(newLed[1], fadeValue);  
analogWrite(newLed[2], fadeValue);
analogWrite(newLed[3], fadeValue);  
analogWrite(newLed[4], fadeValue);  
analogWrite(newLed[5], fadeValue);      
delay(30);                            
} 
for(int fadeValue = 255 ; fadeValue >= 10; fadeValue -=5) { // fade out
analogWrite(newLed[0], fadeValue);
analogWrite(newLed[1], fadeValue);  
analogWrite(newLed[2], fadeValue);
analogWrite(newLed[3], fadeValue);  
analogWrite(newLed[4], fadeValue);  
analogWrite(newLed[5], fadeValue);        
delay(30);   
}  
fadeCycle++;
if (fadeCycle == 6) { // if faded x times LIGHT IT UP
analogWrite(newLed[0], 255);
analogWrite(newLed[1], 255);  
analogWrite(newLed[2], 255);
analogWrite(newLed[3], 255);  
analogWrite(newLed[4], 255);  
analogWrite(newLed[5], 255);    
delay (60000); // pause inbetween animations
}
}
if (fadeCycle == 6) {
blinkCycle = 0; // reset
fadeCycle = 0; // reset
}
}
 
 
 


css.php