I got featured on the Make: blog!

lineup2resistors

Exciting news: I got featured on the Make: blog for a project I’ve been working on for a while: amigurumi resistors rendered in crochet. Basically it’s a really soft and cute form of the resistor.

Here’s the article if you want to check it out and find out how I made them: http://makezine.com/projects/crochet-your-own-adorable-amigurumi-resistor

amigurumi resistor

I’ve also made an amigurumi LED! Click here to check it out.

Product Review: Charlieplexed SparkFun 8×7 LED Array

abccharlieplexedledsanimatedI recently picked up the new SparkFun LED Array – 8×7 to try out some hardcore charlieplexing, and so far it’s been working great.

Quoting Wikipedia, charlieplexing is

“…a technique for driving a multiplexed display in which relatively few I/O pins on a microcontroller are used to drive an array of LEDs. The method uses the tri-state logic capabilities of microcontrollers in order to gain efficiency over traditional multiplexing.”

Charlieplexing itself is a simple idea and can be an extremely efficient way of making an LED grid. However, laying out the wiring of a charlieplexed grid, whether on a breadboard or a PCB, can be complicated and require a bit of thinking. It’s easy to layout a grid with 12 or 20 LEDs, but once you start trying to make grids with 30 or more LEDs, it gets a little crazy.

I love SparkFun’s 8×7 LED Array because it eliminates the need to go through the long process of designing and wiring together the grid. Plus it’s in a neat compact module that can be easily embedded. Out of the box, all I had to do was solder on headers and plug it directly into the digital pins on my Arduino. I didn’t need to wire any external resistors, as they’re already built into the board.100_5200

SparkFun has made an Arduino library for controlling the array that allows you to easily write text and draw shapes and do other interesting things on the grid. However, I wanted to use my array with my Raspberry Pi’s GPIO for the purpose of making an archaic internet-connected game system. I’ve written a single-file class in Python 3 for controlling the array with the Raspberry Pi’s GPIO, called pythonic-charlie, and you can find it here (my first legit GitHub repo! Woot woot!). It’s still under development, and still has bugs that need smoothing, but it allows you to display a list of coordinates, test the grid to verify that it’s wired properly, and display a neat little screensaver. I’m currently working on something that will display text. example-wiring

If you ever wanted to learn how to charlieplex LEDs, SparkFun’s 8×7 LED Array is a really great place to start.

smilefrowncharlieplexedledarrayanimation

Simple Light-Up Continuity Meter

continuity meter lit up arduinoRecently I found that I was at a loss for my digital multimeter (confession: it’s actually my dad’s, which I’ve been borrowing for an indefinite period), and I needed to test the continuity on a PCB. So I quickly scrapped together some parts to make a simple light-up continuity meter.

continutity meter assembledContinuity meters are used to test whether two components or joints in a circuit are continuous, or directly connected. Most multimeters  have a continuity meter built-in. When you touch the meter’s test probes to 2 different, yet connected spots on a breadboard or PCB, the meter will either beep or light up.

My continuity meter lights up when the test probes are connected. I utilized a small breadboard, three alligator clips, a super bright white LED, two needles, electrical tape, and a 330Ω resistor to make my meter. I didn’t have to use any solder, and after I used the excess wire to wrap the breadboard and the battery together, it came together nicely.  It works well!continuity meter finished

Here’s how to make your own!

Materials Needed

You’ll need the following, depending on how you want to make your continuity meter and what parts you have.

  • alligator clips and breadboard (or soldering iron)
  • x2 needles (act as test probes, if you want something more precise than the wire as a test probe)
  • x1 battery or combination of batteries with a combined voltage of 1.5 to 9V, the total voltage being greater than but as close as possible to the voltage drop of the LED
  • x1 resistor, ohm value discussed later
  • x1 LED, you’ll want to know its voltage drop (see here if you don’t know, you’ll have to scroll down a bit)
  • electrical tape, duct tape, or glue for keeping the meter together after assembly

Assembly

  1. The hardest part of building your continuity meter is figuring out the right resistor value to use with the LED. For that, will use a bit of math and Ohm’s Law. You’ll need to know the voltage of your batteries (Vcc) and the voltage drop of your LED (Vd). The forward current limit (I) on most LEDs can be approximated to 0.02A or 20mA, so we’ll use that as our current value. This is how to calculate the resistance (R) of the resistor you’ll need:
    • V = IR
    • R = V/I
    • R = (Vcc – Vd) / I
    • R = (Vcc – Vd) / 0.02
    • For my continuity meter, I had an old 9V battery that measured at 8V and a white LED with a forward voltage drop of about 3V. So I needed an ((8V – 3V) / 0.02mA) = 250 Ω resistor. The closest standard value resistor up is 330Ω, which is what I used.
  2. Next comes assembly. Whether you’re using a soldering iron or a breadboard, it’s simple. Either solder your ‘test probes’ to the wire, or put the needles directly into the alligator clips. Take a look at the diagram below for guidance.  continuity meter diagram
  3. That’s about it. The LED should light up when you touch the two test probes! To containerize your continuity meter, duct tape the battery and excess wires to the breadbread, or if you soldered it, you can try gluing it together.

    continuity meter hands testing lit up

Important Disclaimer about using this continuity meter:

Be careful using your continuity meter. I’d recommend using it only for testing boards and components where you know that things are supposed to be continuously connected. You don’t want to use it as you’re trying to figure out what a board does, you run the risk of shorting out components on the board. Definitely don’t use your homemade continuity meter on circuits that have live power!

Cool Desk Lighting: A Homemade Cagelight

Cagelight in red flashing mode.
Cagelight on, in red flashing mode.

While panning absentmindedly through one of my dad’s farm/tools/random-outdoorsy catalogs, I saw something that really caught my eye: a cagelight that apparently was intended for use in a barn, but looked like it belonged in a mad scientist’s lab. It looked something like this: cagelight example

I immediately decided I needed to make my own version of the cagelight for use as an epic decoration for my mad-sciencey desk. I used some thick wire, LEDs and other electronics, 3D printed parts, and lots of hot glue. It turned out to look like this:

100_5011

This project consisted of two main parts: making a custom PCB to control the light, and designing an authentic cagelight enclosure. I ended up designing and 3D printing a custom case and using heavy gauge wire to make the cage.  Below is what it looks like lit up. It’s quite bright. Basically, a battery powers some white LEDs and some flashing red LEDs which can be switched on and off.

cageligt white light on
The cagelight on, in white-light mode.

Continue reading

Happy Arduino Day 2016 + Testing a Power Relay

Happy Arduino/Genuino Day 2016!

arduino uno pic

Take some time today to do a little project with your Arduino!

Testing a Power Relay

My tech savvy grandma recently got me a very nice IoT power relay! I spent a while testing it out by making a simple system to automatically turn my desk light and my Pi monitor on or off. I hooked an SR-04 ultrasonic sensor to my Arduino Uno and wrote a sketch to have it detect when my hulking mass is close to my desk and send a signal to turn the relay on or off.

power relay hooked up
This is my power relay setup connected to an Arduino and ultrasonic sensor. I taped the ultrasonic sensor down to keep it from wiggling about. The Arduino is being powered by a USB port on my Pi 2.

The most challenging part of creating this little system was getting accurate readings from the ultrasonic sensor. They can read inaccurately if objects are moving around in front of the sensor, and the light would flicker annoyingly if I moved too quickly. I figured out how to smooth the value by reading from the sensor 30 times in 1.5 seconds, and then taking the average of all 30 values.

The power relay works great. It required no setup out of box, and it’s simple to connect your controller. Its only disadvantage is that it doesn’t have an ‘always-on’ power source, which requires you to have an external power source for the device controlling the relay.

iot power relay
This is the power relay I tested.

Check out the sketch I wrote for this project below, or click here to download.

/* 

Using an Arduino with a Power Relay

Parts used:
--ultrasonic sensor
--desk lamp
--Arduino Uno
--120v relay

This sketch uses an ultrasonic sensor to detect whether
a person in near or sitting at a desk, and sends a 
signal to a power relay to turn desk lighting on or off.

*/

#include <NewPing.h>

const int LIGHT = 10;
const int TRIGGER = 12;
const int ECHO = 11;

NewPing sonar(TRIGGER, ECHO);

void setup(){
  pinMode(LIGHT, OUTPUT); 
}

/* The main loop iterates every 2.5 seconds. */

void loop(){
    
  /*In order to get a accurate measure of whether
  someone is near, we read the ultrasonic sensor
  30 times and take the average. That way, if the
  ultrasonic sensor reads sporadically as it 
  occasionally does, those values will be averaged out.  
  This takes 0.05 * 30 = 1.5 seconds to get a value
  from the sensor. */
  
  while (int i, i < 30, i++){
    sum = sum + sonar.ping_cm();
    delay(50);
  }
  int average_distance = sum/30; 
  
  
  /* Using the value, we send a signal to the relay
  depending on whether someone is detected less than 
  130 cm away. We also pause for a second for good 
  measure. */
  
  if (average_distance < 130){
    digitalWrite(LIGHT, HIGH);
    delay(1000);
  }
  
  else{   
    digitalWrite(LIGHT, LOW);
    delay(1000);
  }
}

Tech Tear Down: CD/Radio/Cassette Boombox

It’s been a good long while since I’ve really dissected a bit of electronics. But I finally got another chance after uncovering an old broken CD/radio/cassette player in the basement! After some tests, I determined that the CD player part of it didn’t work. Since no one uses archaic cassette tapes anymore, and a radio that weighs ten pounds is pretty impractical,  I naturally snapped it up to tear it apart. 🙂

boombox before teardown
The boombox before dissection; note that it’s quite dusty. It was manufactured in 1997 so it was about 20 years old.

Disassembling it was pretty trivial. There was only a few screws which held the casing together, and each internal part also held in place with screws. The most challenging part was removing the large speakers. Each was both glued and screwed, so it took a little extra prying to get them off.

The boombox can be powered from both batteries and the house current, so there’s both a transformer and a large compartment to hold eight D cells. There’s one large PCB that combines the circuits for the CD player, cassette player, and radio player, with a few offshoot PCBs to connect the controls.

I was able to salvage some good parts:

  • x1 2-digit 7 segment display
  • x2 DC motors (they’re rather weak)
  • x2 8Ω 3W speakers
  • x1 microswitch
  • x1 large potentiometer
  • x1 fancy radio-tuning gear
  • a few plastic casings for switches and knobs
  • various wires and connectors

Check out the following images of the torn-apart boombox.

Major parts of the boombox.

plastic casing of boombox

tape player part of boombox

closeup of cd player_boombox ttd

bottom half of main pcb_whole radio

closeup of cd player controls

This is one of the large speakers I salvaged.

main pcb of boombox

closeup of radio tuning pcb

Tic Tac Toe Arcade Game with Raspberry Pi

tic tac toe arcade game circuit layout
Final layout of my tic tac toe game

In the event of the Raspberry Pi’s 4th (1st) birthday, I’ve been working on a tic tac toe arcade game using the Raspberry Pi’s GPIO with Python. Basically, a human player battles against the computer on a 3×3 LED grid. The player uses a pushbutton 4-way keypad with a ‘select’ button to play. I also added a speaker and coded some neat sound FX!

Below is a demo of the game:

Hardware

parts to tictactoe arcade game raspberry pi
Parts used for the tic tac toe game

The hardware for this project is pretty basic:

  • Raspberry Pi
  • 9x green LEDs
  • 5x pushbuttons
  • Speaker
  • Trim potentiometer
  • 9x 330Ω resistor
  • 5x 10kΩ resistor
  • Adafruit Pi Cobbler with ribbon cable

    wiring diagram
    Wiring schematic for tic tac toe made with Fritzing

LED Grid Diffuser

In order to make the playing experience more pleasant, I designed a 3×3 grid LED light diffuser and 3D printed it so as to make the light from the LEDs less blinding. It also keeps the LEDs lined up nice and covers some of the wires up too!

Computer AI

This was actually my first experience dealing with any computer AI, and I discovered that it is quite fun! I designed it so it has four logical steps:

  1. First, if there’s any move where the computer will win (i.e. the computer already has two in a row), the computer will play that move.
  2. Second, if the player could win on the next turn, the computer will block it.
  3. Third, if the center of the board hasn’t been played, the computer will play the center.
  4. Finally, if none of the options above are applicable, the computer will play a random move not already played.

Software

For the software, click here. It’s written in Python 3 with the RPi.GPIO library, and it’s actually the longest bit of code that I’ve written as of yet. 🙂

Here’s an extra video with more info about the project:

building the tic tac toe game
Building the final prototype for the tic tac toe game
closeup of tic tac toe circuit raspberry pi
Closeup of LED grid and buttons