Introduction: Programmable Wearable Arc Reactor
This Instructable stems from another that I made when I needed a quick and cheap halloween costume. It was a simple circuit of a button cell and LEDs in a paper housing. You can find more on it at https://www.instructables.com/id/Poor-Mans-Arc-Reactor-Costume/. Since that time I started messing around with NeoPixels in some other projects and realized just how easy they were to manipulate. Then I started tinkering with ATTiny 85 chips and realized there was a whole new world of applications for these super simple addressable LEDs and tiny micro controllers. This was actually my first project to combine the two but I have previously posted another Instructable combining them at https://www.instructables.com/id/Fake-TV-Burglar-Deterrent/.
There are a lot of great Arc Reactor based Instructables on here. My first one was made to be cheap and be in the reach of anyone with any range of soldering skills and basic knowledge of circuits. This one is still relatively inexpensive but is much more advanced and still fits into the same thin profile of the previous build. It is fully programmable and customizable. Maybe you can take what I have done here and use it as inspiration on a build of your own. Or better yet, take it and improve upon it! I look forward to seeing what you all come up with if you attempt this build.
Step 1: Gather Your Materials
Here is my parts list:
- ATTiny 85 - 8 pin microcontroller - purchased mine from Jameco here
- WS2812B RGB LEDs - aka NeoPixels (60 per meter) purchased mine from eBay, see detail below
- 10 uF electrolytic capacitor - pulled out of an assortment pack I purchased from Amazon here
- Resistor #1 - somewhere between 300 and 500 Ohms will be perfect - pulled out of an assortment pack I purchased from Amazon here
- Resistor #2 - 10K-Ohm Resistor, mine came from another project but you could get it from the same assortment pack listed above.
- Hookup wire - helpful to have 3 colors, but not necessary - I think I got mine from RadioShack
- Perfboard - You can either cut your own or purchase a circular board. I got mine at my local RadioShack (2.4" diameter) in a assorted size pack (part #276-004). The holes on this one aren't the best and it is one sided. But it was the best size I could find. You can find it here.
- Button - I picked mine out of an assortment I got from Electronic Goldmine. Any momentary button will do.
- 1S 3.7v LiPo Battery - I had one of these in a cheap RC airplane, you can find it here.
- Battery connector - For connecting the battery. Purchased from Amazon here.
- Header pins - strictly optional. I included them to be able to reprogram the board on the fly.
- Fogged window film
- Black cardstock
- Solder Iron
- Wire snips
I had all of the parts laying around from other projects with the exception of the round perfboard, battery and connector but they are all easy to pick up at many online retailers. The only "high cost" item is the WS2812B LEDs. These are best known by the name NeoPixels as marketed by Adafruit. If you want to support Adafruit then go buy them from their website. I, however, found them for less than half the cost on eBay. I purchased my NeoPixels here. They have worked great on 4 different projects with no dead pixels or any issues whatsoever.
Battery: I really wanted to make this a completely self contained device that was thin and easily mountable under a shirt and remain largely unnoticeable until it was turned on. I elected to use a 1S 3.7v battery to power this project. There are several examples of NeoPixel projects being driven with 3.7v LiPos so I knew I could make it work. The ATTiny is also quite happy running at 3.7v. You could easily power this with anything between 3.5v and 5.5v. I don't suggest going much over 5.5v though as it may fry your NeoPixels. Three 1.5v or 1.2v batteries would also work great, they would just have to be contained in another holder, separate from your Arc Reactor. Obviously your choice, but I wanted mine as slim and professional looking as possible.
LEDs: Adafruit does sell NeoPixels already on a round PCB and ready for use. They may not come in the right diameter or setup that you want though. It really doesn't save you much on soldering in my opinion.
Step 2: Breadboard Your Project
I suggest you breadboard everything before you start soldering. It is always nice to get the bugs worked out BEFORE you have soldered a single connection. With that, I also suggest, if you have an Arduino UNO or other full sized Arduino with headers for easy connections that you program and test the setup before switching over to the ATTiny, it is just much easier to work with.
I am going to show you this setup first with an Arduino Uno serving as the microcontroller. No pins need to be changed or reassigned in the code to make this work. You will see a few steps later that all we then have to do is pull out the wires leading to the Arduino and replace it with the ATTiny, add power supply, and you are ready to test the final setup. For the purposes of breadboarding and the final build I like to use three colors of wire in simple applications like this. Red is always Vcc (Voltage high), Black is always Ground, Green is always Data. Those are the three colors of hookup wire I had available, you may prefer something else. Whatever floats your boat. Place the components like I have shown in the Fritzing diagram above.
WS2812B (aka NeoPixels): Ignore the pins identified in the Fritzing diagram, they do not have WS2812B version. Instead recognize that 5v goes to the solder tab marked "5V" on the strip. Ground goes to "GND". Data is routed from digital pin 4 on the Arduino (also digital pin 4 on the ATTiny 85) through a resistor (between 300 and 500 Ohms) and to the tab marked "DI" on the strip. The capacitor is in place to help remove voltage spikes as pixels flash on and off. There is a great tutorial on these LEDs on Adafruit's website found here. IMPORTANT: If using 11 pixels like me, I suggest using a max brightness of 150 to keep the total current demand down, the Arduino can source 500 mA via USB. IF YOU ARE USING MORE PIXELS you will need to provide an alternate power source for this part of the setup.
Plug the Arduino into your computer via USB. Nothing smoking? Great! Something smoking? BAD!
Step 3: Load the Code
If you have done everything correctly you should be able to just copy and paste this code (attachment) into your Arduino IDE and upload straight to the Arduino. Within seconds you should see the breadboarded prototype glowing in all its glory.
I am only a few months into coding so my code is likely very inefficient and could be picked apart by some of you out there that are far smarter than me. Feel free to comment with any constructive criticism regarding the code. You will need the Adafruit Neopixel library. You can download it here.
About the code:
The program is written to loop through different modes. There are several variables defined at the beginning that are set up to match the number of patterns I used, the brightness I chose to define, data pins, delays to debounce, etc.
Void setup() defines the button pin as an input and then strip.begin and strip.show are declared. This initializes the LED strip and clears it. It is now ready to operate.
Void loop() - chkBtn is calling a function that choses the pattern numerically, I will describe that function later. Then it is followed by an if statement that says if we have surpassed the number of patterns, reset the counter to 1. Then pickPattern is called which refers to the function below.
void pickPattern() - This is a simple switch that takes the pattern number defined by chkBtn and calls the function for individual patterns.
boolean chkBtn() - This function is checking to see if the button is being pressed, if it is, then it will add one to the pattern count and cause the program to select the next pattern.
SteadyLights - Sounds just like it is, all the lights turn on and stay on at a constant level. This is pattern #1 so it will display as soon as the reactor is powered up.
PropSpin - Creates a propeller like spinning animation.
Glow - All lights glow to what is defined in BRIGHTNESS and then fades to zero, then back again.
Smile - Creates a yellow smiley face pattern, cheesy, I know.
Heartbeat - Glows light red followed by a bright "thump, thump" pattern to simulate a heartbeat. As if Tony Stark has a heart...
Spinwheel - One LED at a time is lit and spins around and around, like an iPhone "loading" animation.
Idle - Turns off all LEDs. So you can leave the battery plugged in but temporarily turn off all LEDs and consume very little current to save battery power.
Step 4: Program the ATTiny
Ok, here is where I will gladly point you to other sources. This is really quite simple but does not warrant me rephrasing everything. I first messed around with controlling NeoPixels using ATTiny 85 after reading danasf's post "Use a $1 ATTiny to drive addressable RGB LEDs". It gives you a pretty good guide of how to program your ATTiny 85 for this purpose. It is based on work done by High/Low Tech in which they use your Arduino to program the ATTiny. There are also other solutions, but I liked this one the best.
Find more at High/Low Tech's pages:
Big thing here is to be sure to load the bootloader after selecting the 8 MHz INTERNAL clock. If you burn the fuses wrong it won't work. After you load the bootloader you just then upload the code I supplied and then your ATTiny is programmed and ready for your Arc Reactor! Move on to testing it on the breadboard.
Step 5: Return to the Breadboard - With the ATTiny 85
Now that your ATTiny is programmed you can return to the breadboard.
Pin 1 on the ATTiny 85 is marked with a small dot, arrange the chip such that you are looking at it with the dot in the upper left so you can follow along. Now take a look at the pinout diagram (courtesy of Sparkfun) in the pictures above and prepare to be confused if you are a newbie. The "physical pins" count sequentially down the left side 1,2,3,4 with pin 4 being in the lower left. Then jump across to pin 5 in the lower right and count sequentially up the right side 5,6,7,8. Easy, right? Wrong. Those are the physical pins, but what the microcontroller calls those pins for the purpose of programming is completely different. I will save myself from typing it all out and just focus on the pins we will be using for this application (other than the programming).
Ground: Found on physical pin 4.
Vcc: "Positive" or your voltage high. Found on physical pin 8.
I/O 1: Digital Pin 1. Found on physical pin 6. We are using this as our button input.
I/O 4: Digital Pin 4. Found on physical pin 3. We are using this as the NeoPixel data feed.
Thank goodness someone already put this on a diagram, or my head would hurt.
Remove the wires from the Arduino, wire in your LiPo or other battery pack (Ground first), pop in the ATTiny as shown in the attached Fritzing diagram and you should be up and running with your now shrinkified project. Your program should be working just as before and behaving nicely. Play with the button for patter selection, make sure everything works. If so, you are ready to move on to soldering it all up to your perf board.
Step 6: Install the LEDs
My apologies on this one as I built this a while back and am just now writing the Instructable. I took pictures and will be writing instructions in a way that would be describe each step. Just try not to look ahead if you prefer a step-by-step methodology. Also, this was put together with little layout and planning, I just started working and it developed as it went.
The Arc Reactor I chose to build is one with 10 segments on the outside and one circular center. There are many different looks out there so choose what you want. Lay down the circular perf board with the solder pads facing up. Lay your template down so you can get a good feel for where you should place your LEDs. Since mine had 10 outside segments plus one interior I chose to use 11 LEDs. Use wire snips or scissors to cut the LED strip along the cut lines until you have 11 individual LEDs. I lined them up best as possible with the holes in the template and peeled the backing off and stuck to the perf board. Be sure that all the data arrows are pointing in the same direction. You can see that in my example I installed them all facing counterclockwise. You can do CW or CCW but if you do CW you will have to alter your code. The LED in the center should point "up".
Now it is time to wire the LEDs together. This will help give them some rigidity as you complete the rest of the project. You can use small bits of hookup wire but I have found that the best thing for small distance connections like this is to use spare tin from the legs of resistors, through hole LEDs, etc. When you get the solder hot near these spare bits of tin they almost "jump" into the solder pad. It really makes soldering these connections extremely easy. You need to connect all "ground" pads together around the circle. Next, you need to connect all "Data" pins together, EXCEPT for the "top" two LEDs. If you look at the attached pictures you can see there is a gap between the top two where there is no connection. This is because the Data signal only travels in one direction and can only be connected in series, not parallel if you want the code to work properly. Now solder all the "5V" pads together. You can leave the center LED unconnected for now.
Step 7: Install the Remaining Components
This step is what I did the most of on the fly. You really have a large amount of real estate on this PCB if you do the design the same as mine. The biggest obstacle to work around is the battery. If you are going to have your battery be integral to your build then I suggest laying out all of your components carefully. If you are trying to make it a slim form factor like mine then be sure to account for that. The thickest component in my build is the header pins that I use for troubleshooting and reprogramming. If you plan to leave those out you may shave off a few millimeters from your overall design.
Use the pictures as a guide but ultimately follow the Fritzing Diagram from Step #5 to lead you along the way. The LEDs encircling the board really help to provide GRN and 5V rails.
ATTiny - Be aware of the pinout when choosing your install location. Also, I chose to solder my ATTiny directly to the perfboard versus setting it in a DIP socket in order to make the device thinner. This is the main reason I have header pins soldered on for reprogramming. The header pins actually give a thinner profile than the ATTiny in a DIP socket would have. Be careful when soldering the ATTiny in place, you want minimal contact time between your solder iron and the chip. If you are putting your battery source outside of the Arc Reactor itself you could easily place the ATTiny and majority of non-LED components in or near the battery enclosure. This would give you an extremely slim design.
Header pins - The particular perfboard I used didn't play nice with the header pins. I had to darn near beat the things into the holes. I set them as low as possible while still allowing a female jumper to make a solid connection. If you don't plan to reprogram yours or are planning to put your ATTiny in a DIP socket do yourself a huge favor and leave these off.
Button - Be sure to place your button in a location that will be under an opaque part of your design. You will want to include a spacer on the "lid" of your Arc Reactor that will translate a soft tap on the outside down to the button. You won't want this spacer to be across from the transparent film, it will leave a significant shadow.
Wires on back - These wires (grey, orange, red and yellow in picture) on the back are only really needed if you are trying to program via the header pins. For the purposes of the Fritzing Diagram these have been left off (to alleviate confusion).
Step 8: Plug in the Battery and Test Your Device
If your code is all correct and your connections are all good you should see beautiful white light come streaming forth from your partially complete creation. Push the button and watch the pattern changes take place before your eyes.
If stuff starts smoking, then I'm going to say you did something wrong. Find out what you did wrong and fix it...real helpful, I know.
Step 9: Make the Arc Reactor Enclosure
Now is the part that gives the Arc Reactor its shape and look. Attached is the image that I used to create mine.
Firstly, I wanted the slimmest design possible so it could fit under my shirt and when turned off it wouldn't be noticeable. My final product is 3.5" in diameter and 0.400" thin. It is a great size.
My entire enclosure is made out of black cardstock. Something easy to work with but rigid enough to hold its shape. You can use an Exacto or hobby knife to cut it out. If you have a crafty wife like me you can use her paper cutter to save a lot of time and give you a great looking finished product. I used her Silhouette Cameo paper cutter. These things are like a great 2 axis CNC for paper. You can also use them with vinyl to create your own circuit boards!
I have included a picture and attached a PDF of the Silhouette pattern I used. The dimensions are: Circle shapes = 3.5" diameter. Strips = 0.40" x 9.62". Use clear tape to tape the strips to the circumference of the circles and you are almost home free. These two halve will press fit together to be a tight fit that won't come apart while wearing.
I lined the inside of the back cap with aluminum foil to help reflect all light and hopefully output more to get the right effect.
Step 10: Cut the Diffuser
I used fogged window film that I had laying around to create mine. I cut two circles using the cap as the template. I stacked them inside the front piece in two layers for better diffusion. This seemed to do the trick.
You could use tissue paper or velum and get a similar effect.
Step 11: Plug the Battery in and Put It All Together
I put a small piece of tape over the back of the perfboard to keep it from shorting out on the aluminum foil. Then I taped down the circuit down to keep it centered. I taped the whole thing to my chest with medical tape but you could easily attach it to an elastic strap, hang it from a string around your neck or something else.
See the attached pictures and video so you can see the final product with user selectable modes.
I hope to modify this in the future by creating a better enclosure with a plexiglass face to make it more solid. I am also looking to incorporate a Lipo battery charge and protection circuit to keep the battery from over discharging and to be able to charge the device with two jumpers instead of having to remove the battery.
What enhancements will you make? Please post your Instructables and comment. Link back to my Instructable when you do so everyone can see the progress and improvements you have made.
Hope you enjoyed the Instructable. If you wanted a wearable Arc Reactor but this build was a bit too much for you then check out my other Instructable "Poor Man's Arc Reactor Costume" for a significantly simplified build.