Introduction: Arduino Mini-Shields
This is a set of simple, small form-factor, mini-shields that I created almost by accident. As I made more and more of them, I realized that they could be really useful. What started out as a way to use some spare parts, turned into a standardized form factor for a versatile, miniaturized Arduino shield. The added benefit is that they also make a great kit for traveling, or simplified prototyping or for educating kids and beginners about Arduino.
I have been building some custom shields and modules for a while now but while I like the modularity of a shield, they are a little too expensive and large if all you want to add is just a little piece. The modules I make are all small and have to be plugged into a breadboard, which doesn't have that satisfying, finished feeling I'm looking for. I buy a lot of perf board, but the Arduino boards have this annoyingly unusual spacing between the digital pin banks so you have to modify the pins to make them fit. I needed something that was more flexible, lighter weight, and allowed me to change the pins used more easily to avoid conflicts with other shields.
The Mini-Shield Standard
I started making these small modules with standardized pinouts that are mostly plug and play. I call them Mini-Shields and they include everything you need for almost any application. The first 3 pins from the right of each board are connected to the 5v, ground and Digital 2 pins from the Arduino. All of my mini-shields use the following standard and they work pretty well with each other.
Pin | Pin Function
1 | 5v
2 | Gnd
3 | Digital 2 (Hardware Interrupt)
4 | Analog *
5 | Digital (PWM)
6 | Digital (PWM)
7 | Analog **
8 | Digital
9 | Digital (PWM)
* the Real Time Clock module requires analog pin 4
** the Real Time Clock module requires analog pin 5
I liked the idea that these little modules could be added to almost any other shield and you could swap them out as needed. I would then also be able to reuse them in different projects without too much effort. The standardized pinout meant that every one of them could be used in place of the others if everything was wired correctly. Once they are built, they make a good little, rapid prototyping set that would also work as an entry level set for Arduino beginners.
Shield of Mini-Shields
I made a single shield with space for any 3 mini-shields to be connected at the same time. Each mini-shield uses 2 analog pins, and 4 digital pins (plus digital pin 2 which they all share since I have dedicated it for the hardware interrupt feature). I needed to dedicate analog pins 4 and 5 to slot A to ensure the Real Time Clock module would work. Of the 14 digital pins, there are only 6 PWM pins available, so I have dedicated slots B and C to be the PWM mini-shields, so things like the speaker and the full-color LED won't work well if they are plugged into slot A.
Step 1: Parts and Methods
Debounced Button Mini-Shield - An RC circuit with an inverting Schmidt trigger to debounce the output from a tactile switch.
D Pad Mini-Shield - 5 button directional pad connected to a single analog pin
Bar Graph Mini-Shield - Uses a shift register to light an 8 segment LED Bar graph with only 3 digital pins.
RGB Mini-Shield - An RGB LED & trimmer pot + 2 buttons.
Real Time Clock Mini-Shield - an adapter to use my off the shelf RTC module.
Theremin Mini-Shield - A salvaged PC speaker, photo cell & 2 buttons.
Headers
I made all of these mini-shields with parts I had on hand but I hadn't gotten a chance to use. I always keep a lot of male and female headers on hand. More and more, I like to use these right angle headers which only come as male headers, but I have found you can also bend the pins on the female headers to make them lay down along the board as well. I like the 10 packs of straight and right angle headers that they sell at Schmartboard. Most other places only sell the header strips in singles. Unfortunately, they don't sell the female headers there.
Perf and Proto Boards
I bought a couple of 2 sided, through-hole plated proto boards that I never found a use for. This project gave me a good chance to use them, but once I used the 2 I had, I started cutting pieces off a large perf board that I got at Radio Shack.
Resistors, Capacitors and Components
At some point I stopped buying one type of resistors and I started buying the assorted packs. It's a much better deal and it's more convenient to use something you have on hand than to run to the store and hope you remember all of the things you needed. If you have a bunch to choose from, you can usually mix and match something to work for you.
Buttons
I have been using a lot of buttons lately, and I ran out of new ones but I had a bunch that I salvaged out of an old DVD player so I was able to reuse those as well. When I junk old electronics, I open them up to see what could be useful. If I find anything good, I cut the parts out with a pair of tin snips and put them away. If I need them later, I will use some desoldering braid to remove the solder and free the part from the circuit board. I used the same process for the buttons, the IR LEDs and the IR sensor that I used in this project.
My Method
The wire I use in my projects is just solid core UTP network wire. I have a big spool of wire, so every so often I cut a few feet off and strip off the outer sheath. The wires inside use the standard CAT5 standard, so I don't have red and black wires like I would prefer. Instead I use Orange for Red and Green for Black. I use Blue for switches and other digital pin leads. I use White Blue or White Green for data and analog pin leads.
Header Markings
I used some paint pens to mark the header pins with colors so you can easily tell what pins are necessary and how they should be hooked up to an Arduino from a breadboard. I marked the 5v pins with Red and the GND pins with Green. I marked digital pins with Blue and I marked analog pins with Yellow. I marked the PWM (digital) pins with White, but I put a dot of color in the middle. For the Full-Color LED, I matched the dot to the color that the pin relates to on the LED. I mark the female header pins with white masking tape and fine tip permanent markers using the same color scheme as above.
Step 2: IR Mini-Shield Construction
This was the first mini shield. I had some parts I wanted to add to my Time and Temp shield, but I had no more room on the shield for the parts. I decided to put them on a daughter board with header pins so it's removable and reusable. I had a few of these 9 x 9 hole proto boards that I hadn't found a use for but it turned out 9 holes was exactly the right size for this project.
I salvaged a few IR LEDs out of old TV remotes, and an IR Receiver from an old A/C unit that I thought I could use on the Time and Temp shield. I also thought it would be nice to add a few buttons, so that I could make a menu for the display.
IR LED
First I tested the IR LED from the remote with 5v from the Arduino. I had to look at the LED through my camera to see the infrared glowing. The camera showed that the LED worked fine but it did get hot, so I assumed it was getting too much power. I tried a few different resistors until I didn't see too much difference between full brightness and when the resistor was placed in series with the led. With a 47 ohm resistor, the LED doesn't overheat anymore and still shows full brightness on the camera screen.
IR Sensor
I found a little information on Adafruit about a similar IR Sensor. The board I took this from had markings that indicated the + and - leads were the same as Adafruit's guide said, so I soldered it along the top of the proto board for clearance of the sensor's eye.
Buttons
I had some extra room, so I had to put a couple tactile buttons in place to fill up the space. I like having extra buttons on my projects because there is always a reason to have some way to trigger a process, especially when you are testing something.
Step 3: Debounced Button Mini-Shield
I had another of these 9x9 through-hole plated proto boards so I figured I would make another module that I could use in the same port. I have a section of one of my breadboards devoted to a hardware debounced switch. This way I can hook the switch up to the hardware interrupt on Arduino and begin a new instruction in the middle of a loop. The interrupt pins need to be debounced with hardware because there is no way to use the wait delay to debounce on the interrupt.
There is a really good explanation of hardware debouncing and interrupts on these websites...
http://www.jeremyblum.com/2011/03/07/arduino-tutorial-10-interrupts-and-hardware-debouncing/
http://arduino.cc/en/Reference/attachInterrupt#.UyXvl4XLIyz
Step 4: Directional Pad Mini-Shield
Since the original idea was to add some new inputs for my Time & Temp shield project, I thought a directional pad would be nice. I remembered this post on the Arduino site that only uses 1 analog pin for all of the buttons. Because the resistances are mapped out so nicely, it even allows for the Arduino to recognize combinations of any 2 keys pressed at the same time.
I was trying to use parts I had on hand and I was running out of buttons, so I had to salvage 4 of these buttons from the A/C unit's control panel. I have a set of standard resistors from Radioshack that is getting a little picked over, but I was still able to make something work by combining a few resistors to get the desired resistance.
I had to use 4 resistors for buttons 2 and 3 to make the 390 and 680 values described in this example, and as a result my actual resistance was slightly different, so I had to run the following test code to see what the analog reading would be for each button, and update the button array to allow for these values (usually 1 number above/below the example on the Arduino site).
Test Code:
int analogpin = 3; // analog pin to read the buttons
void setup()
{
Serial.begin(9600);
}
void loop()
{
Serial.println( analogRead(analogpin));
}
Step 5: Bar Graph Mini-Shield
I was thinking of other things that would be useful as a mini-shield and I thought I might like to have an LED bar graph circuit, complete with a shift register on it. I have a nice tricolor bar graph, but its a 10 segment one, and my shift register is only 8 bits. I remembered I had these 8 segment (2 per line) LED displays with a strange pinout and I figured this would be a good chance to use them.
With the shift register driving the LED display on the mini-shield, I can get away with only using the 3 digital pins to light up all 8 LEDs. Otherwise, I couldn't put this on the mini shield since I only have 4 digital pins dedicated to each mini shield. Even if I used the shared pin 3 on the mini-shield connector, I would only have 5 digital pins to drive 8 segments. The shift register makes it possible to drive more LEDs without exceeding your available pins.
Parts
74HC595 Shift register - These shift registers are great for increasing the number of output pins so you can drive many LEDs from just 3 pins on the Arduino. You can daisy chain them together to get even more output pins, you only need to change your code to allow for the additional shift registers. There is a good tutorial for these here.
LED 8 segment bar graph - I have these in a couple different colors because I was trying to string a lot of them together with daisy chained shift registers. The ones I used here were not what I expected so they were never used.
Resistor Network - I have 2 different kinds of these, Isolated and Bussed. This one is isolated so it contains 8 separate resistors, but I dragged a line of solder down the outgoing leads to tie the grounds together. If I had used the bussed one, I could have just used the one common lead for the ground, but I would have been wasting 7 additional resistor leads.
Step 6: RGB LED Mini-Shield
I have a few different kinds of full color RGB LEDs that I occasionally hook up on a breadboard, but when I need space on a breadboard they go right back in a drawer. I thought one of these might make a good mini shield. To take up the rest of the space, I included a few more buttons and a trimmer pot because they are always handy.
I went to the product page on Sparkfun and looked at the datasheet. These have apparently been discontinued, but it's basically the same idea for any full color RGB LED. This one happens to be a common cathode LED, if you have a common anode LED, wire the common pin to 5v instead of to the ground like I did.
To pick the resistors, I went to this page and plugged in the values I got from the product page. This site recommended a 150Ω resistor, but the LED was still too bright and hurt my eyes to look at it, so I ended up going with 220Ω resistors.
I soldered the LED, the 2 switches and the 10k trimmer pot to the perf board first, then I worked on adding the other pieces. I tied the 5v leads and the ground leads together and worked on tying the LEDs, and switches to the digital pins and the wiper of the potentiometer to one of the analog pins. If I had thought more about this, I would have reversed the polarity on the trimmer pot, because I have to turn the knob to the right to decrease and left to increase, which is counter-intuitive.
Step 7: Theremin Mini-Shield
This one originally started out as just a speaker shield because I had a PC speaker I salvaged from an old motherboard. Then I remembered I had a Photoresistor or Light Dependent Resistor (LDR) that I salvaged from a nightlight and I decided halfway through the project to include the LDR as well. So I decided to bundle the parts necessary for a pseudo-theremin onto one mini-shield.
I used these guides on Adafruit for the general circuit layout and code.
http://learn.adafruit.com/adafruit-arduino-lesson-10-making-sounds/pseudo-theramin
http://learn.adafruit.com/adafruit-arduino-lesson-10-making-sounds/arduino-code
Step 8: Real Time Clock Mini-Shield
I like this Real Time Clock module a lot. It allows you to keep perfect time while your Arduino is busy doing other things. I added some female headers to another project to allow me to plug this in and use it, but now I want to be able to use it as a mini-shield, so I decided to make an adapter board.
This module is really simple to wire up, it only needs 5v power, ground, and analog pins 4 and 5. To make this adapter, I just needed to wire up the Arduino's analog pins 4 and 5 as the 2 analog pins in the mini-shield connector.
Adafruit has a very nice guide to using this module with Arduino.
Step 9: Shield of Mini-Shields
After I had a few of these mini shields, I thought I might like to use them together on one shield. That way I could have a nice ready-made kit that would allow many different combinations of sensors and outputs. I made a new full size shield that I could plug up to 3 mini shields into. 2 ports are vertical and 1 is laying down.
When I laid out the pins, I had to think about what kind of mini-shields would go where. The RTC mini-shield needs to have analog pins A4 and A5 because they aare required by the library. My RGB LED and Theremin mini-shields both need 3 PWM capable pins, and since the UNO has 6 PWM pins, I would like to use 3 for shield B and 3 for shield C. My debounced button mini-shield needs to have either digital pin D2 or D3 to access the hardware interrupt, since D3 is also a PWM pin, I decided to use D2. Since I really only need this for 1 shield right now, and I can't imagine needing 2 interrupting shields, I decided to connect D2 to all 3 mini-shield ports.
As I explained earlier, this is the standard mini-shield pin layout:
Pin | Pin Function
1 | 5v
2 | Gnd
3 | Digital 2 (Hardware Interrupt)
4 | Analog *
5 | Digital (PWM)
6 | Digital (PWM)
7 | Analog **
8 | Digital
9 | Digital (PWM)
* the Real Time Clock module requires analog pin 4
** the Real Time Clock module requires analog pin 5
And here is the layout for all 3 mini-shield header ports:
Mini-Shield Pin | Arduino Pin
A1 | 5v
A2 | Gnd
A3 | Digital 2 (Hardware Interrupt)
A4 | Analog 5 (Required for RTC module)
A5 | Digital 7
A6 | Digital 8
A7 | Analog 4 (Required for RTC module)
A8 | Digital 12
A9 | Digital 13
---------------------------------
B1 | 5v
B2 | Gnd
B3 | Digital 2 (Hardware Interrupt)
B4 | Analog 3
B5 | Digital 9 (PWM)
B6 | Digital 10 (PWM)
B7 | Analog 2
B8 | Digital 4
B9 | Digital 11 (PWM)
---------------------------------
C1 | 5v
C2 | Gnd
C3 | Digital 2 (Hardware Interrupt)
C4 | Analog 0
C5 | Digital 3 (PWM)
C6 | Digital 5 (PWM)
C7 | Analog 1
C8 | Digital 1
C9 | Digital 6 (PWM)
Step 10: Adding Mini-Shields to Existing Projects
I bent some of the wires on the shield out of the way so I could squeeze the row of 9 female header pins in place.
I bent the pins on the headers so they will clear the screen and the module I built will lay flat. Unfortunately, I had to bend the header back up to solder in the holes underneath it. I don't know if it would have been simpler to solder the header in after I soldered the jumper wires to the Arduino digital pins, or if that would have caused other confusion. This worked out, but its tough to bend something flush to the board. Usually to get a perfect bend, you have to go slightly past where you want it, and I didn't have the room to do that here.
The Time and Temp shield was the first board I added the mini-shield port to, so this one was kind of shoehorned into place. I didn't come up with my pin standard until later, but this one still follows most of the standards I defined later.
The mini-shield on my tank robot is not finished yet. I need to decide what is important and what will not interfere with any of my other shields. Currently I have an DSRobot motor controller shield and a Sparkfun Xbee shield that the mini-shield port is soldered to in the prototyping area. The Xbee shield has a bluetooth module plugged into the Xbee port.
Step 11: Finish
I'm very happy with how these mini-shields came out. I have a couple others in mind for future projects and I think it would be handy to make a simple adapter for every pre-made module I can find. Specifically, I have my eye on an ultrasonic sensor adapter for my tank robot and a humidity sensor for my Time & Temp shield.