Friday, May 19, 2017

Working with Organs and Arduino

Sometime in mid-October I received a call from my friend asking for a 3d printed brain, heat, and set of lungs.  I thought about it for a moment and told her that I could make it pretty cool...and that's how one of my favorite projects was started. 

Finding the STLs to use wasn't too hard, making them usable was a little more difficult.
  • Heart - http://www.thingiverse.com/thing:932606
  • Lungs - http://www.thingiverse.com/thing:1234899
  • Brain - http://www.thingiverse.com/thing:478336

The heart was already hollowed out and ready to go, the Brain was pretty simple because I was able to make a smaller brain and cut out the insides with it.  The lungs were a much bigger problem, because of their weird shape they were difficult to hollow out, and even hollowed it seemed like the supports would use more filament than just printing them solid.  Here comes the biggest mistake from this project.

I decided it would be perfectly fine to print the lungs, and then hollow them out with a drill.  This was a very bad idea.  Sure it worked perfectly fine, but it took forever and felt like a waste of time.  The fact that I had to print the lungs in 8 parts because it was too big for my printer just made it take longer.

As soon as the organs were finished printing I started on the electronics which were relatively easy to put together, it is basically the same setup I had in my last project (so check that out if you want to learn more).  The coding was a little more troublesome.  This was my first endeavor into Object Oriented Programming with C++ so things went a little slow at first.

The Code

The basic plan was to make an organ class and give it attributes for each of the organs.  I'm not going to post this code though, it looks really ugly.  Maybe at some point in the future I'll come back and fix it.

The final plan was to have one arduino connected to each organ, but I was thinking it may be fun to recreate this in the future and have one arduino run all three organs, so I took a more fun route that required me to figure out how to multi-task! (Adadfruit has a pretty good tutorial here)

.  Normally people program Arduinos to run of a single loop, so if I want a light to flash every two seconds I may write something like:
  1. Wait 2 Seconds (delay())
  2. Flash Light
This works perfectly fine for this application, but what if I want a light to flash every 2 seconds, and another to flash every three seconds? The second command stops the entire program, which makes it impossible for these two commands to run simultaneously. Even if I tried to get a light to flash on the third second, it would ruin the first command.
  1. Wait 2 Seconds (delay())
  2. Flash Light -Light Flashes on the 2 second mark
  3. Wait 1 Second
  4. Flash Light - Light Flashes on the 3 second mark
  5. (Loop Beings again)
  6. Wait 2 Seconds
  7. Flash Light - Light Flashed on the 5 second mark, when we wanted it to flash on 4 
This is where a handy command called millis() comes in to play.  millis() will tell you how many milliseconds the Arduino has been running  and based on this we can much more easily fix the problem above with something that looks like this (bear with me, it will be a bit more complicated)
  1. time = millis()
    light1_time =0
    light2_time=0
  2.  if time - light1_time > 2 seconds
    then Flash Light and set light1_time = time
  3.  if time - light2_time > 3 seconds
    then Flash Light and set light2_time = time
As this program loops around it is constantly checking if it has been two or three seconds since the last time it lit, and the light1_time keeps track of the last time it was lit.  And tada! It works!

The code itself replicates each organ.  The lights in the brain randomly light up with varying colors and intensities.  The lungs slowly get brighter and darker, and the heart beats at about 60 beats per minute!


The Hardware

When all the components were finished, it was time to assemble them. The hardware was pretty easy to assemble, it's the exact same layout as my previous Stranger Things build following the same safety precautions to not damage the leds.  The only difference was that I used a lot more shrink wrap.  These are intended to be used at a festival so there is the very real chance that it could rain.  I didn't set up a final box to hold the arduino themselves, but I suggested that they get some plastic containers, cut a hole out of the lid and stick everything in, then superglue the crap out of it.




The Bragging

Look at them and their awesomeness!



How do I hold all these organs?
I have an idea!

























And now to see all of the actually working!

A post shared by Steven Burgess (@stevenryanburgess) on

A post shared by Steven Burgess (@stevenryanburgess) on

A post shared by Steven Burgess (@stevenryanburgess) on
jkljljlkj

Tuesday, January 17, 2017

Stranger Arduino Things

Halloween is a magical time where people have a chance to shed their persona, and adopt another, be it a Dracula, a robot, or one of Backstreet Boys. But more importantly Halloween is a time for makers to show off their new projects!  What a shame it is that they only get one day... The least I could do for my newest favorite project is to devote a blog post to it!

After seeing 'Stranger Things' the first time I was hooked, good actors, excellent production value, and a plot that pulls you in from beginning to end. Most importantly it had a scene that I knew I needed to emulate.  If you haven't seen the show I don't suggest reading further or you'll find some spoilers.

The wall from 'Stranger Things'
In a tense scene Joyce Byers is desperately trying to communicate with her son who is in some other realm of existence (the Upside Down).  She quickly realizes that he is trying to contact her through the lights in the house, and Joyce rigs together what you can see on the right.  So I thought to myself, why not make a portable wall so people in the Upside Down can communicate with me on the go?

I knew the setup would be pretty simply. Use and Arduino Nano, follow the standard hookups for Programmable Leds with an Arduino (add a resistor in front of the pin you are using to control the lights to help prevent damage to the pin, and a pretty large capacitor across the + and - wires coming from the power source to help smooth the current so the leds don't get damaged), battery case, and various art supplies.  Now it was time to get the code for the leds working.

The leds I purchased could be controlled by the Fast LED Arduino library pretty easily, and after a few hours I was able to get my proof of concept to work! 

A video posted by Steven Burgess (@stevenryanburgess) on


Around this time I started to see people posting their own versions of the project on Reddit.  There were a handful of example codes that I could have used, but what's the fun in that?  I trudged on, and with a little more work I ended up with the full program! You can find the code at my Github here.  It's pretty simple to use and change, the main thing you'll need to know about is the 'lightUp' function.  It take the led number, and then the r, g, and b color values.  For a little added authenticity I preset the color for each led to match the corresponding color of lightbulb in the show!

With all of the technical stuff working it was time to move onto the arty parts!  I set up my mini studio and dove in!

I started off with a base layer that was a bit similar to the wall's color, but I ended up going with a slightly brighter color because I wanted more contrast for when it was dark outside.  After that I painted some flowers and started with the letters.

Originally I wanted to have a font closer to what is shown in the series, but after I painted the letters I realized that they were too thin to read easily. After another layer I finished what you see below.


 The next step was to attach the leds to the poster-board, superglue wasn't going to work so I ended up using wire.  All I needed to do was jab it through the poster board and with a quick twist it was ready! (I did need to tape a piece of cardboard on top of the twisted wire so it wouldn't scratch up my chest)  All that was left was a strap so I could hang it on my neck and that was easily made with some duck tape.



I'm pretty happy about the final result, and can't wait to find an excuse to wear it again in the future!