Electronic Birthday Card

My sister’s birthday is coming up  so I decided to make her something personal that you can’t easily get in a store. And because it’s me, of course it has to have flashing lights and at least one microcontroller in it. In this post, I’ll detail how I built and programmed a device using a generic LCD screen module, an Atmega328p, and other simple parts.

Before soldering anything together, I always try to prototype on a breadboard. Because I hadn’t used these LCD modules before this project, I figured out how to interface with them. I got them for next to nothing on eBay but was fairly sure they had an arduino library floating around somewhere. And sure enough, there absolutely was! The LiquidCrystal library makes it super simple to enter text, and easily lets you create custom characters. I based my code off the CustomCharacter example, and used the “man” and the “heart” icons.

The LCD itself connects without too much trouble; power and ground for the LCD, and power/ground for the LED with current limiting resistor for the backlight. Four data pins and two more for Reset and Enable, and then you’re good to go to use the LCD library. The contrast is adjusted with a potentiometer tied to the VO pin. I’ll definitely be using these cheap displays in future projects, as long as I have six pins available and need a low-res display.

For the animation itself, I made it so two stick figures would walk on screen, carrying a line of hearts. Then the message “Happy Birthday Amanda” shows after that, first in all caps and then with normal capitalization. See the end of this post for a demonstration.

You can find my code at the following link: https://github.com/tedmyers/Bday_LCD

(link opens in a new window/tab)



After making sure I could properly interface with the LCD and animating everything, I moved on to programming and testing the Atmega328. I set it up on a breadboard, connected the appropriate power and ground pins, pullup on reset, and attached a 16MHz crystal oscillator.

Next it was time to program the chip. If I wanted to, I could’ve just uploaded my sketch by placing it in my Arduino Uno (after loading a bootloader onto the chip) but where would be the fun in that?

I used a 6-pin ICSP breadboard breakout, the Bus Pirate v3.6, and a custom 5×2 socket cable and adapters from 5×2 to 3×2 at the end. I had some trouble here and eventually figured out that the 5×2 to 3×2 ICSP adapter board I ordered from Amazon a while back was faulty; the solder hadn’t properly flowed on the CLK pin and was causing my programming to fail. Luckily I was able to fix this easily with a touch of the soldering iron after figuring out the problem.


Here’s a clearer image of the programming setup for the Atmega328

Next I found the .hex file that Arduino generated and uploaded it with the following command:

avrdude -p m328 -P /dev/cu.usbserial-AL008K5E -c buspirate -U flash:w:Bday_LCD_Code.cpp.hex

And now the animation was playing , but not quite right; it was much too slow. The fuse bits were still set to prescale the clock by a factor of eight. I then reprogrammed the fuses with the following command:

avrdude -p m328 -P /dev/cu.usbserial-AL008K5E -c buspirate -U lfuse:w:0xff:m -U hfuse:w:0xde:m -U efuse:w:0x05:m

And everything worked. On a side note, avrdude seemed to be displaying the incorrect high/extended fuse bytes. I’m not sure why this was the case, but either way the clock was no longer being prescaled and my animation was working as designed.


Now that everything was working on a breadboard, I soldered everything up. I soldered the LCD module onto a protoboard and lined up everything I needed. You can see each component in the picture below:

  • Atmega328 microcontroller
  • 16MHz crystal oscillator
  • 2x 22pF capacitors
  • 0.1uF capacitor
  • 10uF capacitor
  • 10k Potentiometer
  • Power Switch (SPDT)
  • DC Power jack

In the end I decided to opt out of the ICSP header, as I wasn’t planning on reprogramming the chip after the initial time. As a compromise, I used a dip-socket so I could pop it out and reprogram if necessary.


I decided to “slot” the LCD on top of the main circuit. This way the LCD screen is front and foremost, and the final product doesn’t end up too large. I was planning on shipping this across the country after all, and don’t need a gigantic PCB. I also like trying to fit everything in a small space, and think I did it fairly well in the end.


Here you can see the finished product of a few hours  of soldering. I decided to also add a power indicator LED, and I used the slow color fading “smart” LEDs from adafruit (https://www.adafruit.com/product/679) to both indicate that the power switch has been turned on, and to add an interesting backlight/underglow effect.


Here you can see how messy my desk gets when working on a project.


And finally, the finished product! I had to debug it a little due to human error in some solder joints, but otherwise this project went pretty smoothly! It’s always nice when you can catch your flaws soon enough to make something cool without too much hassle; I’d definitely recommend testing and prototyping before undertaking any project.

Now sit back, relax, and enjoy the video of it in action!



After all this work, I packed it up in a box with a 5V power adapter that plugs into the power jack, taped it up, and shipped it off to my sister.

I hope you enjoyed hearing about this little project I made for my sister, and hope you remember to show appreciation for your family and friends!

$0 Bluetooth Adapter

About a year ago, I bought a pair of bluetooth earbuds. I got them for a very cheap price (somewhere around $10-15), and used them successfully throughout the summer. Unfortunately, one day the left earpiece popped out broke, leaving two wires poking out of the black plastic case. They worked perfectly fine except for the one broken piece, and I was out of an otherwise perfectly fine pair of bluetooth earbuds.

The broken headphones

After having these sit around in a drawer for a couple months, I decided to take them apart to see how they worked and if I could salvage anything.

Opening the case revealed that one of the earbuds had a charging port and battery, and the other had the control electronics.

taking it apart

My idea at that point was to scrap the earbuds, which are just tiny speakers, and solder on a 3.5mm audio jack so I could connect my speakers to them. This would turn my broken earbuds into a working Bluetooth receiver, something which I had wanted to purchase anyway.

After prying the plastic housing away, I cut the wires connecting the two halves together and examined the circuitry hidden within. Interestingly  enough, the wires coming from the micro-USB charging port go all the way across the headphone wire to the control board, and then other wires go all the way back to the battery. This actually makes sense, because the control circuitry needs to monitor the lipo battery voltage; it is important to not over-charge a lithium battery, and the board controls flow of charge to ensure that this does not happen.


After taking the board apart I found an enclosure to put everything in; I didn’t want bare electronics sliding around on my desk. I settled on an empty headphone case, the ones Apple earbuds come in. I still had mine, untouched since I got my new phone and otherwise just taking up space in my drawer. I haven’t heard of anyone reusing this case; it’s just packaging that almost everyone throws away after getting their headphones. The final component was the 3.5mm headphone jack. I found a pair of earbuds in the trash at work and grabbed it knowing I could repurpose what would have otherwise been trash into something I could use.

I planned out where the micro USB charging port would go, and drilled out a hole for the headphone jack wire. I used a dremel to cut the proper shape for the USB port, which you can see cut out in later pictures.


Next, I stripped the wires from both the headphone cord and the Bluetooth earbud’s circuitry. If you’ve ever stripped wires from earbuds or  headphones,you know how annoying  this is. I find these wires really annoying because they’re so hard to work with. They are very thin and coated with a nonconductive enameling, so you need to be very  careful; a simple pair is of wire strippers won’t get you anywhere with these wires.

After removing the outer plastic sheathing with wire strippers or careful cutting with flush cutters, you’ll find many thin wires and possibly some electrical  shielding. (Braided copper wire or a thin foil). Sometimes there will be a wire wrapped in additional braiding. After separating out each wire, the insulation needs to be removed. I’ve been told that using sandpaper is a good method, but I didn’t have any sandpaper at the time. The enameling can also be burned off with a lighter and scraped away. This method leaves a charred looking piece of wire, but if done carefully can work well for the time and effort spent.

After taking the time to match up and solder the correct wires together, I placed it into the case. I had to refer to a chart for how to wire up the 3.5mm jack, and tested it with the speaker on my desk to make sure that I was wiring up the correct channels together. You don’t want to mix left and right, or make a worse mistake that would cause everything to work.

After putting everything in the case, there was plenty of room to spare which I was fine with; it’s still a low profile case that has the nice look of apple’s design once the lid is on.

I used hot glue to keep everything stuck, and lined up the micro usb port with its hole I cut and the microphone to a small hole I drilled in the case (I don’t plan on using it, but may as well put it in).

And finally, I was done!


I now have a bluetooth adapter made completely of repurposed headphone parts that would have been thrown out otherwise. This project only took me a single night’s work after getting all my materials together, and I’m proud that I was able to make something useful with my old stuff. Now I can stream my music over bluetooth and listen to it through my speakers.

I hope you enjoyed my project, and perhaps have inspired you to make something useful out of the things that you normally throw away in your life.



R2R DAC for Oscilloscope Graphics


A few months ago, I purchased an old analog oscilloscope. Nothing fancy, just the basics I needed to get familiar with using a scope. I wanted to figure out how to use this piece of test equipment, and plus the glowing green screen and abundance of very clicky knobs looks (and feels) pretty cool.

In this post I will explain the basics of what an oscilloscope is, the difference between PWM and analog voltages, and how to create an digital to analog converter to create analog voltages with a microcontroller. With two analog signals, I will then draw vectors on an oscilloscope screen in order to display graphics and text.

What is an Oscilloscope?

My Oscilloscope

An oscilloscope works by plotting a voltage over time. That way, you can very easily visualize signals. On older analog scopes, they actually deflect an beam of electrons to make a moving dot on a phosphorescent screen to create a line. But newer digital oscilloscopes still work in pretty much the same way. Oscilloscopes are a very important tool in electronics because they allow engineers and technicians to see the electrical pulses and signals that occur inside electric circuits, even when they occur very rapidly.

One cool example of an oscilloscope in use is visualizing an amplified audio signal. This makes a very sci-fi and robotic waveform, and lets you see how sound is made up of waves of varying frequency.

One of the problems I had after I got my oscilloscope was that I had no signals to measure! With an Arduino or other microcontroller platform, you can easily make a 0-5V square wave by pulling a pin high and low in a regular patter. This is somewhat interesting, but is not using the scope to nearly its full potential.

My Arduino Uno can also produce a PWM signal, (short for pulse-width-modulated signal). This means it can very quickly (in the MHz to high kHz range) go from 0-5V with varying duty cycles (amount of time 0V compared to amount on 5V). This shows up on my oscilloscope as a square wave that changes the width of time high.

This signal is produced by the following code:

for (int iii=0; iii<256; iii++)


analogWrite(outuptPin, iii);


Producing an Analog Voltage

A PWM signal can mimic an analog voltage by providing the same average power, but it isn’t truly an analog value. 50% 0V and 50% 5V doesn’t equal 2.5V, especially if your sample rate is high.

So, now we face a problem: how do we get an analog voltage from pins that can only produce 0 or 5V? A device that does this is called a DAC (Digital to Analog Converter). One way is to use capacitors to “smooth” a PWM signal. The goal is to choose a capacitor sufficiently large such that it takes more time than the width of the pulse to charge or discharge. This will produce a voltage that is between 0 and 5V depending on the duty cycle, but is also fairly slow, because it needs to allow the capacitor to charge and change its voltage.

Another option is to use a circuit composed of resistors connected in a particular way, called an R2R circuit. This is a very simple circuit that allows multiple binary signals to be converted into a single analog output.

Image from Wikipedia Page on R2R Resistor Ladder: shows the circuit diagram for an R2R circuit.

It is called an R2R circuit because it only requires two arbitrary values of resistors; one simply needs to be twice the other. Thus, one is labeled R and the other two times R (2R).

One cool thing about this circuit is that you can make any voltage you want, and your precision goes up the more pins you go up. As you count up in binary (000, 001, 010, 011, 100, etc). The voltage produced at point A will correspondingly change. It worked really well for my project because:

  • It’s fast: very little delay
  • Easy to make: you only need two values of resistor (or one if you use two of the same in series where 2R goes)
  • Cheap (because it is only made of resistors, which cost fractions of cents)
  • Works well with Arduino: using the PORT functions you can quickly and easily write binary values to multiple pins at once, perfect for this application

Here’s a video that explains how this circuit works very well, using Thevenin’s superposition theorem to explain how to simplify the circuit:

My original prototyped R2R circuit. Here, you can see my Arduino Uno connected to the circuit and my oscilloscope probe.

After this circuit is put together, and the digital signals connected to an Arduino’s PORT pins, we can create analog signals. I started with a ramp, as it is a simple changing signal that can I can easily visually inspect with my oscilloscope.


Success! The circuit works, and now I can create quickly changing analog values with my Arduino Uno and a simple circuit of resistors.

Putting it all Together

The next step is to use the new ability to quickly create analog voltages to create the image we want on the oscilloscope screen. With two R2R circuits (one on the UNO’s PORTB and the other on PORTD), we can create two independent voltages simultaneously. With the oscilloscope on X-Y mode, the voltage on probe 1 controls the x-position, and the voltage on probe 2 controls the y-position. Therefore, it becomes possible to make the display “draw” lines by incrementing each value.

All Soldered! Lots of resistors in the end. Instead of using two values of one R and the other 2R Ohms, I connected two resistors of the same value in series to create an equivalent resistance of 2R.
The back side of the board. I connected male pin headers, so I could plug it straight into the PORT registers of my UNO.

The first thing I displayed on my oscilloscope was a circle, because it is a simple combination of a sine and cosine wave. Here’s what each signal looks like. You can see the x and y component of the image, as two identical waves spaced 90 degrees apart.

The X and Y components of a circle (shown below).


Here’s another test image, this time one of a starburst. This is basically made up of ramps with periodic amplitude.

The signals that create the “starburst” pattern. You can see that each signal is made up of various ramps.
A closer image of the signal of the x-axis for the starburst pattern
Finally, the starburst pattern itself.


Now we want to be able to draw vectors on the display, so we can create an image out of points connected by lines. Basically, a connect-the-dots type of image.

Because the DAC we have contains 256 discrete steps, we can’t technically make any “smooth” line. A way to work within these constraints is common in computer graphics applications, as pixels often need to represent vector-based graphics. The code I’m using employs Bresenham’s line drawing algorithm to create a line between two given points with the function line() which has inputs of x1, y1, x2, and y2, as the start and end points of the vector.

Image from wikipedia page of Bresenham’s Algorithm. Shows how it efficiently draws pixels in appropriate locations to display vectors within a pixel grid.

And that’s the main idea of the code. With the coordinates of each vertex of an image, the code runs through each point and draws vectors between each point.

I started with the image of a logo I made a decade or so ago, this picture:


And then plotted a points to represent it with straight lines, within a 0 to 255 grid (because we have 256 steps of resolution).

plotting TED

And finally wrote down all these points and loaded them into an array that is programmed into the Arduino Uno.

Spinning Around

Now if we want the logo to “spin”, the x-coordinates are changed in a periodic sinusoidal fashion to compress into a center line. If you want to see more information about how to do what I have described here, I recommend you watch the following videos:

Great Scott video:

In the first video, W2AEW goes over most if not all of everything that I have mentioned here. His code is at this link:


It was from his youtube video that I was inspired to mimic the idea of using an R2R circuit to create spinning graphics, and I am thankful for all of the interesting things I have learned along the way.

Electronic Dice Roller


This post details a project I recently finished, an electronic dice roller. My goal for this device was to display the result of a simulated “dice roll”, allowing for easy and quick generation of the sum of random numbers from 1 to n, where n is chosen by the user. This can be helpful in many role-playing games such as Dungeons and Dragons, where there are many times you need to roll something like two six sided dice (2d6), one twenty-sided dice (1d20), or three eight-sided dice for example (3d8).

Layout and Planning

After a few iterations of different screen designs and button layouts, I settled on a final design.

Preliminary design sketches/ideas:

(click to enlarge images)

My finalized design employed the use of a 128×64 pixel OLED display, mainly because of its flexibility: I could easily change my graphical interface as opposed to, say, seven-segment LED displays which severely limit the number of digits that can be displayed. They also are more complicated to use because you need many output pins and therefore would be forced to add extra components such as shift registers to make it work with a microcontroller of a limited number of pins.

The screen I got on Amazon also is dual color, in the sense that the first 16 rows are yellow, and the rest blue. This was perfect for my application because it fits my graphical layout (number of dice rolled at top in yellow, and blue for the larger text result). Plus, it just looks nicer than a single-color screen.

Final Schematic
My final sketched schematic and plan for laying out components

Apart from viewing the screen, the user interacts with the dice roller by pressing the “roll” button (the red upper button) which rolls the selected number of dice with the selected number of sides, or the “add” button (the yellow lower button) which adds a new roll to the number already displayed on the screen. The number of dice and modifier can be seen at the top yellow portion of the screen, and the roll result in a blue larger font at the bottom. If the result is greater than three digits, an error message is shown, as only three digits can fit on the screen.

buttons gif
The device in use: first rolling 1d20 (the default value), then the user changes it to 2d8-3, rolls a few times, and then presses the “add” button to add a number of rolls together.

The values for number of dice rolled, number of sides, and the modifier added or subtracted can be easily changed by using the knob: when pressed, it cycles which area is highlighted, and the value can be modified by turning the knob clockwise or counterclockwise. This makes changing settings quick and intuitive, and allows for very quick rolling of various amounts of dice.

screen gif
Close-up of the screen



Now I had to program my Arduino to do what I needed it to: interface with a screen, read the input from two buttons, and adjust values based on a rotary encoder.

Luckily, communicating with the screen was made quick and simple because of Adafruit’s Libraries. (SSD1306 for interfacing with the driver chip for the screen, and their GFX library for quickly and easily adding text or shapes to the display.)

The rotary encoder used external interrupts, which are a very useful feature that the ATMega328 has and the Arduino IDE has support for. It allows code to be ran only when a pin changes, and otherwise will not slow down the main loop() program by polling with the digitalRead() function. You can read more about this useful feature here: http://playground.arduino.cc/Code/Interrupts


After prototyping my design with my Arduino Uno and a breadboard, I arranged each part on a proto board. I also decided to use a bare ATMega328 chip because of its ease of use from prototyping on my Uno and integrating it into my final circuit. Because it is the chip that runs my Arduino, putting it in my final circuit is as easy as popping the chip out, soldering the connections in place, adding a 16Mhz crystal oscillator and 22pF capacitors, and adding a pull-up resistor to stop the reset from activating.

Figuring out where to most efficiently place components
Figuring out where to most efficiently place components

From the beginning, I wanted this project to run on an external battery, and a 9V battery seemed perfect for this task. I used a 5V linear voltage regulator to supply the microcontroller and display with the correct voltage. I added a 10uF capacitor on the output because it needs it for stability reasons, and a 0.1uF decoupling capacitor, though this is probably not necessary.

Finally I added the screen, which partially covers the voltage regulator and microchip to keep the device as compact as possible. After that was done (and after testing to make sure it all actually worked), I cut the extra protoboard to size, to make it fit better inside a case.

I also connected a power switch in series with the battery source to allow it to be turned on and off. And finally it works! A small, compact self-contained package that now does exactly what I want: to roll dice. All I need to do is build a case to house my newly-soldered electronics.

The guts of the device, before the housing was made
The guts of the device, before the housing was made

Instead of using a generic black box housing, I wanted to make my own unique case. I also liked the idea of making it out of metal and luckily I had some scrap laying around from taking apart an old fax machine.

The entrails of the fax machine, spread out on my table. The scrap metal can be seen in the bottom right of the image (the long grey rectangle with slots cut out)

To shape the metal to the case, I  started by using calipers to measure my electronics, and made a 2d CAD image of the screen, knob, and button layout in SolidWorks to aid in cutting in the right spots. Next, I printed this on a piece of paper at 1:1 scale, cut the paper to shape, and taped my image onto the metal sheet. After using a marker to transfer the cutout shapes over, I had a template to cut holes for the case that were placed in the exact right spots.

I then used a dremel with a cutting wheel attachment to make the hole for the buttons and screen, and a large drill bit to make the circle for the knob. If I were to redo this step, I would have drilled out my button holes as well, as it is very difficult to make square holes of the size I needed, and I ended up using round LEDs to reach the buttons anyway. Oh well, now I know how to do it better next time.

After I cut the holes in the front plate of the case, I also cut a piece for the back and used my dremel with a different attachment to sand away the metal and change the finish from a matte look to a snazzier brushed metal look.

After I cut the metal to size for the front and back, I needed to find something to reach the buttons, and needed some sort of spacer to stop the whole thing from squishing together too much, at least enough so the buttons would not be pressed continuously.

As you already know, I used red and yellow LEDs not as a source of light, but to reach the momentary buttons soldered to the board. These actually worked astonishingly well, after some modifications. First I cut off their leads and added athin ring of hot glue around their base as a way to prevent the LEDs from sliding out of the case when it was fully assembled. One thing I actually could have done  is make the buttons themselves light up when pressed, but at this point in the project I just wanted to have a finished project. Maybe I’ll make some cool light-up buttons on the next thing I make.

I made the spacers out of fairly small aluminum tubing, and hot glued them in place. This isn’t the most rugged case, but it should do for my purposes. I spaced the back far enough to easily fit a 9V battery, hot glued the switch to the front side of the case, and closed it all up with black gaffer’s tape.

And, now it’s done!


I’ll leave you with some more images of the device. Thanks for reading!

Front View
Rear View
Side View (right)
Button close-up


  • 5V Linear Voltage Regulator (LM317?)
  • 2 x 22pF Capacitors
  • 16Mhz Crystal Oscillator
  • 10 uF Capacitor
  • 2 x Momentary push buttons
  • Atmega 328 Microcontroller
  • 1 x Rotary Encoder with integrated pushbutton
  • Knob for Rotary Encoder
  • 3 x 10 kOhm Resistors
  • 128×64 pixel OLED display
  • Solder and wire for connections
  • Prototype Board
  • 9V Battery snap leads
  • On/Off switch (SPST)


  • Hot glue
  • Dremel for cutting protoboard and creating case
  • Scrap metal for case
  • Black tape
  • Thin tubing for spacers

Winning the AAPT Photo Competition

This news is a bit old (from 2014), but I thought I should post it because I would like this site to log some of my major accomplishments.

In July 2014 I won the American Association of Physics Teachers’ high school physics photo contest. AAPT is an organization that collects and judges thousands of entries from hundreds of different schools across America and internationally.

The photo I submitted won first place in the contrived category (as opposed to natural), and I am very proud of the work and effort I put into it. I’d like to thank Mr. Lapp, my high school physics teacher, for encouraging his students to take excellent photos and doing his best to connect with every student to teach them in the best way he can.

You can find my photo and its accompanying essay on AAPT’s website here: AAPT Winner 2014, Contrived

Taking the Photo

I went through many iterations trying to take the best photo I could. I also didn’t have any way of triggering my flash to capture the droplet at an exact time, so each shoot I took at least 100 photos and picked out the few best timed and in focus shots.

My camera and background setup

Here’s how I set my camera up. In my first round of photos I used a plain white background, and I didn’t know how my photos would turn out. The key to droplet photography is the external flash, which you can see placed to the right of the small tupperware container in the photo above. With the aid of a darkened room, this makes the only light exposed on the camera’s sensor be at the exact desired instant, in this case right after the droplet hits the water. Coupled with a steady tripod and macro lens (or in my case the much less expensive set of macro extension tubes for my ordinary lens), this  is a recipe for taking up-close shots of the exact instant of a droplet hitting the surface of water.

My personal favorite of this shoot

_MG_8390 _MG_8415 _MG_8441

This turned out much better than I expected, and from that moment on I knew that I had a passion for droplet photography.

Fast forward a little bit, and I was now thinking of interesting photo ideas relating to physics. I knew that water droplets diffracted light, so my first idea was to use a background and see how the droplet altered the image I saw.


This was somewhat interesting, but now I was thinking of optics; I had seen droplets with a sort of “i” shape, with a column of water and a spherical droplet at the top. I knew spheres acted as converging lenses, and could display an inverted image of a real object. So I tested it by writing the word “physics” upside-down on a piece of paper and trying it out.

_MG_3125Success! So after that I printed a more colorful “Physics” image, trying to evoke more ideas of light, refraction, and wavelengths of light by using rainbow. Plus, why not show a bit of pride? So that’s how I ended up with my final image: a lot of iterations, many out of focus and mis-timed photos, and finally a successful finished image.

Water Droplet Acts as Converging Lens

I hope you enjoyed reading about my physics photo, and just as a bonus for reading this far I’ll show you some more physics related photos I took in Mr. Lapp’s physics class. Some also appear in his self-written physics textbook.

curved mirror - Ted-Myers
This image shows how a concave mirror (in this case a vanity/shaving mirror) can cause an image larger than the real object (in this case a silver whistle)
TIR - Ted-Myers
This photo illustrates total internal refraction, when the difference in optical characteriscis of two mediums causes a mirror-like effect where all light if reflected past a certain degree form the normal. This caused a double-headed quarter effect
Static Electricity - Ted-Myers
A spark of electricity bridging two copper wires, illustrating how high voltage electricity can ionize air in its effort to find the path of least resistance
First Law of Motion - Ted-Myers
A photo I actually took about a year prior to the class, this photo illustrates Newton’s first law of motion; that an object at rest tends to stay at rest. In this case, the water in a balloon keeps its shape for a short while after the outer balloon has been popped
Uniform Circular Motion - Ted-Myers
This is a drill spinning a piece of burning steel wool, creating streaks tangential to its otherwise circular path when small molten fragments fly off. This shows that the centripetal force acts towards the center of rotation, and otherwise would travel in a linear path
Capturing the popping of a balloon via a microphone and the flash device

Flash Trigger Device Using the ATtiny85

Making a Flash Trigger using Arduino code on an ATtiny85

Front view of the flash trigger deviceBackside of Flash Device


In this post I’ll go over how I created a high-speed flash triggering device, as well as detailing how it works. Since creating this project I have learned a lot more about electronics and using the Arduino platform, and thus there parts of this device I would do differently now. But even with the mistakes I made then, this project was a great way to get me into prototyping my own devices that stand alone and perform a useful function.

What is it?

First, lets go over what it does: When a laser is crossed, an external camera flash is triggered.

The flash can also be triggered by a microphone, which will cause the flash to fire once a certain noise threshold has been reached.

So, why is this useful? A controlled flash makes it a lot easier to get consistent high speed photos. Think of this example: you want to capture a falling milk droplet right as it hits a surface; the idea is that the laser and sensor are set up so the droplet will cross the laser and cause the flash to fire, causing light to hit the camera’s sensor only at the instant that the laser is crossed.

In my device, I also added a display and adjustment knob so I can add a very specific delay, which is useful when you want the flash to fire later, so I can more easily capture specific instants after the droplet splashes up again. This allows for more flexibility in the laser placement.

Here’s a photo I took with the same scenario that I just described:


Note: The delay was actually one of my problems: due to the way my code ran, it caused too much delay. This is because the main loop of my program took too much time to run, as it would read the analog values of various pins on my microcontroller and output the delay to a screen. Were I to do this project again on the same platform, I would use external interrupts which allow a much faster execution time, as they only execute their relevant code the instant after the signal is received and don’t have to take time out of the main code loop to poll a sensor.

Now that you know the basics of what it does, lets go over how it works.

How it Works

I started by using my Arduino Uno to make an external camera flash fire. It’s a fairly simple procedure to make an external camera flash fire with an arduino. First, lets go over how the flash triggering works. Most external flashes have a port on the side, to plug in what is called the PC sync cable. You make the flash fire by completing the circuit between two terminals using this cable. This is also possible on most flashes through the hotshoe mount, which allows for proper flash firing when attached to a camera.

Because there’s a lot of current running through these wires for a short period of time, we need to isolate it from the arduino circuit. I used a photocoupler, which has a small light-emitting diode and a sensor in it. This means that when a voltage is applied through two of the pins, current can freely flow between two other pins, allowing us to control current without directly allowing it to flow through our arduino circuit (and thus isolating it). Interestingly enough, there is a small LED inside the DIP package, meaning a current-limiting resistor needs to be placed in series with the input pins. It is the lighting of this LED which allows the current to flow on the other two pins.

Here’s a demonstration of the photocoupler in action, allowing an LED to be lit up.

ooh, flashy lights!
When the input (left side) of the photocoupler is connected to power, the LED is able to draw current and light up. Notice that 330 Ohm resistors are used on both sides, because there is an LED inside the photocoupler, and the red LED on the right also needs a current limiting resistor.

(Shot of LED lighting up when the two pins are applied current, or a graphic showing current flow with arrows)

So all we need to do to make a flash fire is use our arduino to create a +5V signal on one of its pins, place a resistor in series so it doesn’t burn out the photocoupler, and connect the two wires coming from the flash to the other side of the photocoupler.

Now that the arduino can cause our flash to fire, we need to find a way to trigger the arduino’s command. I chose to use a laser and a photoresistor to make the flash fire at the instant the light from the laser ceases to shine on the photoresistor.

An arduino can only directly measure voltage, not resistance; therefore we need to set up a voltage divider with another resistor connected in series to the photoresistor for the arduino to obtain useful data about light. This way, when the photoresistor changes its resistance, we can quantitatively measure it. And of course, we’ll need a laser. You can get cheap red lasers nearly anywhere these days. In fact, I ordered ten little 5V modules for less than five dollars. I soldered one of these onto some longer wires and a tripod mount by cutting ¼” threaded metal couplers in half and taping them on.

You could do this, or use any other bright light source, as long as it will constantly stay on the photoresistor until you want the flash to be triggered. Now that we can get data about light hitting the sensor, we’re ready to start with our program.

Programming and the ATtiny

Getting into the Arduino IDE

I won’t go too far into the code I wrote, but I’ll try to touch on everything I needed to make the device work.

First, I prototyped my device using an Arduino Uno. When I was making this, (Winter of 2014), I had only been working with electronics and the Arduino platform for maybe a month or two, when I found time during school. It was during winter break that I was really able to dig into it more and make a larger project such as this. I also continue to be amazed by the support and communities around Arduino and how easy it is to set up  a project and find answers to any questions that pop up while working on electronics.

One thing that I wanted to do with this project was have a nice, easy-to-read display. I had ordered a bunch of 7-segment displays online for pretty cheap and I like the look of them so I thought I’d go with that. Because  you need to be able to control a lot of outputs to light the LEDs inside the display, I used shift registers (74HC595) to control the display.

Shows how I connected each pin of a shift register to a 7-segment display
How I connected each pin of a shift register to a 7-segment display

I didn’t know about shift registers before making this, and I think they’re a really interesting way to expand the number of pins you can control by using only three outputs on a microcontroller. It works by having a communication protocol that uses three pins: one as a clock, to tell the register when to store each bit; one to actually send the data, as a digital 0 or 1 by sending a 0V or 5V signal; and the last one as a “latch”, to tell the shift register to output the data, causing it to create a digital signal on its eight output pins, corresponding to the data that was sequentially sent to its data pin.

Here’s a video with more information about shift registers, if you want to learn more: https://youtu.be/6BLj9Ak2Djs

With the help of four shift registers, I was able to control the values displayed on four seven-segment displays.

After figuring out how to use my displays, I just had to program and put it together. I used a 10kOhm potentiometer to select how many milliseconds of delay time I wanted. I am able to do this because the Arduino has an ADC (analog to digital converter), so it is easy to map its voltage to a 0-1000 millisecond delay.

My code allows for selecting a sound mode, or a laser mode. Each reads an analog value, but this time from a pin which is connected to either a microphone unit or the photoresistor mentioned earlier in its voltage divider setup. When one of these crosses a certain voltage threshold (which was fine-tuned by me earlier), it sends a signal to the photocoupler, allowing current to flow through the flash.

Flash fires after crossing laser threshold with finger
Flash fires after crossing laser threshold with finger

So generally, that’s how it works. Power, the sensor, and the flash unit are connected with screw terminals; there are four 7-segment displays which display the amount of delay; and the main input is a potentiometer that you turn to adjust values and enter the menu to change settings.

Next, we need to load the code onto an ATtiny. Luckily, there is a fairly easy way to do this with an Arduino Uno. With only a 10 micro-Farad capacitor and an Arduino, the serial data from your computer can be loaded onto the very small ATtiny chip. This website, http://highlowtech.org/?p=1695, has complete details on how to do it. With the new Arduino IDE, you can even download their libraries very easily, and can easily run the Uno as an ISP.

This is a key step that allowed me to move past the need to connect my Uno each time and let me make a stand-alone unit.


It was a lot of work soldering everything all together, especially with every connection I needed for the seven-segment displays. I added a 1/4 inch audio jack, which connects to the flash via the PC sync cable. Next, everything was wired up to an 8-pin IC socket adapter, where I could plug in the ATtiny85. Four shift registers were added, the potentiometer, and the screw terminals.

Here’s some images showing my planning process and the wires being soldered into place:

IMG_0749 IMG_0824 IMG_0825

After all that work, I finally had a working product! I decided to also make a nice plexiglass housing, to make it a little more robust and create a more “finished” look.

IMG_0831 IMG_0832

_MG_8101 _MG_8102


  • 4x 74HC595 Shift Registers
  • 4x Common Cathode 7-segment displays with “.”
  • 5x 330 ohm resistors (I used 1/6W)
  • 10k Potentiometer and knob
  • female ¼” female threaded connector
  • ATtiny85 and 8-Pin IC holder
  • Screw terminals
  • Various colors of ~22 gauge insulated wire
  • 1-2x 10uF capacitors
  • 3x 0.1uF capacitors
  • 1x Photocoupler (I used a 4-pin)
  • Laser Modules
  • Optical Resistor and 10k Ohm resistor
  • Double-sided Prototyping Board

Optional (for housing)

  • 4x Machine screws
  • 4x Nuts
  • 4x Washers
  • 4x Lock washers
  • Aluminium Tubing


Front view of the flash trigger device
Front view of the flash trigger device


And finally, I have a finished product! As I mentioned earlier, there are a few things I would do differently if I were to make this again, but I am very happy with what I made. I went from very little experience with electronics to making a finished product with a flashy screen, working input, and ability to improve my photography. I hope you have enjoyed learning about what I have made, and I’ll leave you with some photos that I have taken with this device.


_MG_7869 _MG_7918 _MG_7931 _MG_7935 _MG_7944 _MG_7960 _MG_7967 _MG_7976 droplet