Evil Mad Science Meggy Jr RGB User manual

Meggy Jr RGB
- LED Matrix Game Development Kit -
Making the World a Better Place,One Evil Mad Scientist at a Time
Evil Mad Scientist Laboratories
Support: http://www.evilmadscientist.com/forum/
Kit version 1.0
Manual v. 1.01
An open-source hardware+software project designed by
Distributed by
Evil Mad Science LLC
http://EvilMadScience.com/

Meggy Jr RGB is a handheld platform for developing your own pixel-scale video
games. Meggy Jr has an 8x8 LED matrix display, six comfy buttons, a noise making
device, and even 8 extra LEDs for whatever you like. Meggy Jr can run on batteries
or external power. Meggy Jr is fast, programmable, open source and hackable.
Meet Meggy Junior !
(Also: 16 MHz Crystal oscillator, ISP programming
interface, AAA battery box, a place to put a power
jack, power selector jumper, extra holes to access
ADC inputs of microcontroller and more.)
Mounting holes:
While these are normally used for mounting
Meggy Jr in a set of cool handles, you can
actually attach Meggy Jr to almost anything.
(Robo-Meggy Jr, anyone?)
CPU:
An ATmega168, which is a type
of AVR microcontroller.
(You can also use an ’88 or ‘328.)
8x8 RGB LED Matrix Display:
That’s 192 LEDs all together. The LED matrix is
socketed so that you can pull it out if necessary.
Lo-Fi speaker:
Bzzt! Bleep! Bloop!
Printed circuit board:
White with black printing.
Outline: 5.300” x 2.800”
(About 13.5 x 7.1 cm)
Buttons:
Six big, comfy 12 mm
pushbutton switches with
molded key caps.
USB-TTL interface
If you have a USB-TTL cable, you
can use this port to program or
communicate with Meggy Jr, much
like you would with an Arduino.
Auxiliary LEDs:
Eight extra LEDs-- not in the matrix-- that can be used
(for example) to indicate lives, score, ammo, or level.
LED driver chips & transistors:
These components manage the current needed to
drive all those LEDs. Hidden underneath the LED
matrix display.
Reset Button:
Optional but included with
the kit. Push to reboot.
Meggy Jr is here to play.
[Meggy Jr RGB] [2]
STEP 0: Intro & Tour

STEP 1: Tool Checklist
Essential tools: Needed to build the kit:
1. Soldering iron + solder 1. Resistor lead forming tool
3. Hot Glue Gun
Optional but recommended:
Allows fast, neat bending of resistor leads.
This one is Speedy Bend 801, Mouser part
#5166-801 (~$8)
For clipping loose wire ends close to the circuit board.
e.g., Sears Craftsman
A basic soldering iron meant for electronics, with a reasonably
fine point tip. We recommend one of this design-- a "pencil
shape" soldering iron (not gun!) with a base that holds the iron
and a wet sponge. A tip in good condition (a “tinned” tip)
should get shiny when hot-- able to melt and wet to solder.
While you don’t need an expensive one, the iron can make a
big difference in the time needed to build the kit. (Seriously. If
you use one that is old and busted, or a $10 radio shack iron,
or that thing from the dollar store, please expect to spend at
least twice as long soldering!)
Our recommendation for a low-cost iron:
model WLC100 by Weller, about $40.
[Meggy Jr RGB] [3]
2. Angle flush cutters
For various nimble-fingered tasks.
e.g., Sears Craftsman. The Sears Craftsman #45671
mini-plier set includes both the clippers and pliers
shown here.
3. Small fine-point plier set
(Alkaline recommended.)
4. AAA batteries (3)
You’ll also need some solder. Thin rosin-core solder (roughly
.020 - .040” in diameter) is the most common and best choice
for this application. Either standard (lead-bearing) or newer
“lead free” solder types will both work just fine.
Just one dab of glue for strain relief, near the end.
2.Wire strippers
There’s one place near the end of the build where it’s
convenient (but optional) to shorten and strip two
wires. This model is our favorite: Ideal T-Stripper
#45-121 (the 14-24 gauge size).
And for Programming...
Reprogramming Meggy Jr is not required, but if you wish to do so, you’ll need some things.
1. USB-TTL Cable
FTDI model TTL-232R or equivalent. A “smart” converter
cable with a USB interface chip inside. One end hooks up
to your USB port, the other to Meggy Jr. This allows you to
program Meggy Jr through the Arduino development
environment (http://arduino.cc/).
Alternately, Meggy Jr can be programmed through an AVR
ISP programmer, like the USBtinyISP.
2. Computer, Internet access, USB port....
All of the software that you’ll need is available online for
free. You’ll need a reasonably recent vintage computer (Mac,
Windows, or Linux) and internet access.
Get started here: http://www.evilmadscientist.com/go/meggyjr

Line
Designation
Value
Type
QTY
1
Circuit board
Meggy Jr RGB
1
2
R1, R2
1 k
Resistor, 1/4 W
2
3
R3
100 ohm
Resistor, 1/4 W
1
4
R4
10 k
Resistor, 1/6 W
1
5
RB0 - RB8
620 ohm
Resistor, 1/4 W
9
6
Q0-Q8
2STX2220
PNP Transistor
10
7
J2, J3
10-pin right-angle single-row header (break to 3,6)
10-pin right-angle single-row header (break to 3,6)
1
8
L1
Magnetic buzzer/speaker
1
9
U2,U3
STP16DP05B1R LED driver chips
2
10
U1
ATmega168-20PU Microcontroller
(pre-programmed in kits)
1
11
C7,C8
18 pF
Capacitor, ceramic
2
12
XTL
16 MHz
oscillator crystal
1
13
C3
1200 uF, 6.3 V
Cap., electrolytic
1
14
C1,C2,C4,C5,C6
0.1 uF
Capacitor, ceramic
5
15
D0-D7
3mm LEDs, yellow diffused
8
16
J1
6-pin DIL header
1
17
U4 (sockets)
10-pin SIP socket
4
18
U4
BL-M23B881RGB
8x8 RGB LED matrix
1
19
S1
Tactile Button Switch (reset)
1
20
b0 - b5
Tactile Button Switches, type B3F-4050 or similar
Tactile Button Switches, type B3F-4050 or similar
6
21
Battery Box
3 x AAA cell with wire leads and switch
1
22
J3 (jumper)
Header jumper fits onto J3 after soldering
Header jumper fits onto J3 after soldering
1
23
b0,b1
KeyCap, Round
2
24
b2,b3,b4,b5
KeyCap, Square
4
25
Rubber feet
1/16” thick by 1/4” diameter, hard urethane
4
26
Nylon Screw
3/4” x 4-40
4
27
Nylon acorn nut
4-40
4
28
Velcro Strip
~1”x2”, w/ extra strength adhesive
1
[Meggy Jr RGB] [4]
For the sake of clarity, kit contents are
sorted into a few different bags of
parts.
Most of the parts are labeled by their
line item number that appears on the
from the bill of materials ( ).
(While it can create some interesting
mystery, we do not actually suggest
that you dump all the parts out into a
big pile. Just take them out of their
bags as needed.)
This table lists the kit contents, roughly in the order of assembly.
It is not (repeat: not) a set of build instructions! There are a few
places where the operations and their order is important for
(possibly) subtle reasons; please follow along as we go through the
steps, even if you are an expert.
Meggy Jr kit!
The first part on our list is #1,
the Meggy Jr printed circuit board:
In most of the remaining steps, we’ll be
adding components to this circuit board.
STEP 2: Bill of Materials

Implied procedure for adding electronic components:
1. Bend the leads of components as needed.
(Resistors need to be bent, most others parts do not.
Optionally use lead forming tool shown in Step 1.)
2. Insert each component into the circuit board, from
the top, at its given location. Push it flush to the board.
(Resistors are unpolarized; they can go in either way.)
3. On the back side, gently bend the leads out at 45°
to hold components in place while you solder.
4. One at a time, from the back side, solder the leads of
the component to the circuit board.
5. Clip off extra leads on back side, flush to the board.
(But not so flush that you’re clipping the board itself.)
Bend!
Insert!
Bend out!
Solder!
Clip!
[Meggy Jr RGB] [5]
STEP 3: Adding first components... (and how to do it!)
Part #2 is a 1 kilo-ohm resistor
(Color code: Brown-Black-Red-Gold)
Add two of these resistors to the circuit board,
in locations R1 and R2.
• Your tip should be shiny (tinned). If not, melt some fresh
solder against it and wipe clean on a wet sponge.
• Place the solder against the joint that you wish to connect.
• Touch the iron to the solder and joint for about one second.
Count it out:“one thousand one.”
• The solder should melt to the joint and leave a shiny
wet-looking joint. If not, let cool and try again.
Here!

[Meggy Jr RGB] [6]
STEP 4: The rest of the resistors, and transistor prep
Part #3 is a 100 ohm resistor
(Color code: Brown-Black-Brown-Gold)
Add one resistor the circuit board, in location R3.
Part #4 is a 10 kilo-ohm resistor
(Color code: Brown-Black-Orange-Gold)
Also: it’s the one smaller-size resistor!
Add one resistor the circuit board, in location R4.
R3
R4
Part #5 is a 620 ohm resistor
(Color code: Blue-Red-Brown-Gold)
Add 9 resistors to the circuit board,
in locations RB0 through RB8.
RB’s
Part #6 is a transistor
You’ll need nine, in locations Q0 through Q8.
They need a little prep before soldering.
(Note: the kit includes one extra transistor.)
(Transistors!)
1.Orient a transistor with the flat side (the
side with the writing) facing you. Grip it, near
the top, with your fine point pliers as shown.
(Sturdy tweezers can also be used for this.)
2. Bend the leads up towards you 90°, so that they
stick out straight. Then, spread the leads out
slightly so that they aren’t quite so close together.
(Gripping them with the pliers while doing this lets you
make a tight bend with only minimal stress on the
device.)

[Meggy Jr RGB] [7]
STEP 5: Add transistors and prep right-angle headers
Add the transistors to the board.
In locations Q0 through Q8, insert the transistors with the flat
side down, all the way flush to the board. The orientation is
important: The flat side should be over the dotted-line square
that contains the component name. Solder in place all three pins
of each transistor and trim their leads.
Flush!
The board so far...
Part #7 is a 10-pin right-angle header
This “break-away” header splits into the
parts that go into locations J2 and J3.
1. Using small pliers, grip the first
three positions of the header.
Hold the rest of the pins-- tight--
with your fingers.
2. Holding steady the pins between your
fingers, rock the pliers back and forth to split
the header in two. It will either split into two
parts as 6/4 pins or 7/3 pins. (Either is okay.)
3. Trim the excess pin away to
end up with a 3-pin header and a 6-pin
header, which we’ll use in the next step.

[Meggy Jr RGB] [8]
STEP 6: Add right-angle headers and speaker
Add the right-angle headers to the board.
Add the 6-pin header in location J2, and the 3-pin
header in location J3. The pins fit loosely in the holes.
It may be helpful to tack them in place with a piece of
tape (touching the plastic part only) while you solder
the first pin.
Check after soldering the first pin to make sure that
the header pins are level to the board.
Part #8 is a magnetic speaker/buzzer.
Add this component to location L1 in the
upper left corner of the circuit board.
The speaker has a marking on the top (“+”) to indicate
its orientation. (There are also corresponding marks
on the bottom side for + and -.)
Insert the speaker into the board with the “+” pin into
the matching “+” labeled hole on the circuit board and
solder it in place.
Part #9 is an LED driver chip.
(Type STP16DP05B1R or similar)
There are two of these, that go in locations U2, U3.
First, figure out which way is which on the chips.
The most important feature to notice on the
chips is the “half-moon” indentation at one
end of the chip. This is the polarity marker.
(Other markings on the chips may vary.)

[Meggy Jr RGB] [9]
STEP 7: Add the Chips
Now add the LED driver chips, U2, U3.
The chips should easily slip into the board. If
necessary, bend the leads of the chip to straight
up and down before inserting the chip. Do not
bend them by hand; bend all pins on one side at a
time by pushing them against a hard flat surface.
From end of chip:
YES
NO
Orientation-- very important-- Half-moon end of chip
matches that of the drawing on the circuit board
Press the chips flush onto the circuit board
and solder them in place. You will be
soldering directly to the pins of the chips, so
try to keep your soldering time to about
one second per pin.
(See also soldering tips in Step 3.)
To keep the chips in place while you
solder, slightly bend out the corner pins
on the back side of the circuit board.
Part #10 is the microcontroller.
Add the pre-programmed ATmega168 microcontroller
in location U1. Again, pay close attention to the
orientation of the device on the board, matching the
half-moon end of the chip to the half-moon shape on
the printed circuit board.
In particular, note that this chip is upside down with
respect to the other two chips-- the label “U1” is
written upside down to emphasize that point.
As with the last chips, press this one flush onto the
board and solder it into place.

[Meggy Jr RGB] [10]
STEP 8: Crystals & Caps
Upper right corner of circuit board:
Part #11 is an 18 pF ceramic capacitor
Add two capacitors at locations C7 and C8.
(Like resistors, you can put these in either way.)
Note: The labels on these tiny capacitors are
approximately invisibly small-- they are the two little
caps that are bagged and/or taped together.
Part #12 is a 16 MHz crystal oscillator
A shiny steel can. Install this component in location XTL on
the circuit board, flush to the board as usual. The two pins go
in the outer two holes of location XTL; you can ignore the
middle hole. (Orientation: Either way.)
Part #13 is a 1200 µF capacitor
After a little prep, this component will be installed
in location C3.
Orientation matters: the negative side of the
capacitor is marked with a broad white stripe.
Note:The side of the crystal oscillator
may (or may not) rub up against one
pin of the microcontroller (U1).This
is not a concern in either case.
+-
1.Orient the capacitor with the negative side
(the side with the broad stripe) facing you.
Grip it, near the top, with your fine point
pliers as shown.
2.Bend the leads down 90°, so that they
stick straight down.
(Gripping them with the pliers while bending
lets you make a tight bend with only minimal
stress on the device.)

[Meggy Jr RGB] [11]
STEP 9: The Capacitors Strike Back
Add the properly bent capacitor in location C3.
The capacitor is larger than the outline of the drawing on the circuit
board but will still fit in place. Be sure that the negative side of the
capacitor goes to the side of the side marked “-” on the circuit board.
Push the capacitor flush to the circuit board and solder it in place.
Part #14 is a 0.1 µF ceramic capacitor
Add five of these capacitors, in locations C1,
C2, C4, C5 and C6. (Orientation: Either
way.)
Again, the labels are tiny. If your eyes are very
good, you might be able to make out the
legend “104” on these.
Note: C4 is almost underneath C3; you can
bend it out a little bit for a better fit if needed.

[Meggy Jr RGB] [12]
STEP 10: Leetle LEDs & Optional ISP connector
Part #15 is a tiny 3mm diffused yellow LED
We’re adding 8 of these LEDs to the board,
in locations D0 through D7.
The orientation matters. Each LED has a flat facet on the
plastic top on one side. That side also has a short lead.
This side of the LED goes into the round hole.
The other side has a long lead and goes to the square hole.
Flat facet
Short lead
&
Long lead
Like so: Long lead (first!)
into the square hole.
Then push the LEDs flush to the
board and solder them in place.
Part #16 is a 6-pin dual inline header
>>An OPTIONAL PART that most users SHOULD NOT INSTALL.
(It’s an auxiliary programming port for use with AVR ISP
programmers. Do not add this to your circuit board unless you
already have and plan to use an ISP programmer. It is not needed
for using Meggy Jr or for programming through a USB-TTL cable.)
If you’re really sure that you need it, add it on the back side of
the circuit board, underneath marked location J1.
Marking on the top side
Installed on bottom side
(Pin 1 is marked.)

[Meggy Jr RGB] [13]
STEP 11: Socketing the LED Matrix Display
Parts #17 & #18: LED display and its sockets
The 8x8 LED matrix display sits in a set of socket strips on the
circuit board at location U4.
It has lots of pins, so it can (potentially) be difficult to insert
into a socket. To make it much easier, we’ll instead add the
sockets to the display and do so in small segments.
#18: 8x8 RGB
LED Matrix Display
#17: 10-pin
“SIP” socket strips
(4 pieces)
1. Start with the LED matrix display upside
down. To avoid scratching the black paint
on the front, set it on a clean soft surface like
a piece of paper. (This page will do nicely!)
2. With (a bit of wiggle and) firm even pressure,
slide one of the four socket strips onto the LED
display pins as shown.
The 10-pin socket strip goes over 8 pins of the
display, leaving two pins hanging off the edge. Also,
it should as far down onto the pins as shown-- it
should not sit near the top of the pins.
If the LED display pins are initially bent a bit away
from vertical, you may need to gently adjust to them
to help the socket strip fit on neatly.
3. Use small pliers to gently break off
the two extra pins hanging off the edge.
4. Add the other three socket strips to the LED display the same way.
This completes the socket assembly; next, we’ll add it to the board!

[Meggy Jr RGB] [14]
STEP 12: Add the Socketed LED Matrix Display and the Button Switches
Add the socketed display in location U4.
Set the socketed display into its
position (U4), with the labeled edge
on the left side as shown.
Position the display flat, resting
gently (near the top) on large
capacitor (C3). The pins of the
socket should barely extend past
the back side of the circuit board;
solder them in place.
U4, Oriented with
label HERE:
After the socket pins are soldered in place, the LED
display can be removed (with a firm rocking motion)
and put back in place if necessary.
(Almost there!!!)
Part #19 is a small tactile button switch.
This is an OPTIONAL PART that is not required (but might be nice).
If installed, the Meggy Jr RGB will be reset (i.e., rebooted) when you
push this button. If you want it, snap it into location S1 (Reset), and
solder all four pins from the back side.
Part #20 is a large tactile button switch.
Six of these snap into locations b0 through b5: the
gameplay button locations. Each has six pins: four metal
pins and two plastic pins that help keep it in place.
Be careful! When this snaps into the board, those metal
pins can poke you, so don’t put your fingers right where it
will snap through. (And solder the four metal pins, but not
the two plastic ones.)

[Meggy Jr RGB] [15]
STEP 13: Battery Box, Power Source Jumper,...
Part #21 is a 3 x AAA battery box w/ switch
The wires from the battery box go to the holes that are (on the
top of the board) labeled VCC_IN (red wire) and GND_IN (black
wire).
They enter the board from the back side (where those two holes
are labeled “+” and “-”) and are soldered on the top side.
The wires supplied are longer than necessary, given the position
that the battery box sits in (see photo). But, if you happen to have a
pair of wire strippers handy, you can cut the wires a bit shorter
before attaching them. (See also step 16.) (From back side)
After soldering the wires, it is
recommended to cover the
point where they enter the
board with a small glob of hot
glue, to provide strain relief.
(RED wire)
(BLACK wire)
Part #22 is a small header jumper
Connect the jumper over the left two pins of
J3 when running Meggy Jr off of batteries, or
over the two right pins to draw power from
an external source like an ac adapter.
Note: J4 is a location to install a
power jack on the reverse side
of the board. Your ac adapter
should output for 4.5 - 5V dc,
regulated, center-positive, with
at least 600 mA capacity.

[Meggy Jr RGB] [16]
STEP 14: Button Caps & Rubber Feet
Parts #23 &24 are molded button key caps
These six button caps snap onto the large tactile button switches.
First, add the four square button caps (angled at 45°) on the left hand
side, and then snap the two round ones onto the right-hand buttons.
(If necessary for some reason, the caps can be removed by gently
prying them off with a small flathead screwdriver.)
Part #25 is a hard urethane rubber foot
Install these four clear rubber bumpers to the bottom of the
circuit board, on flat parts of the board close to the four screw
hole locations. Suggested locations are shown in circles.
Meggy Jr RGB is designed to be mounted and used inside a handle set (case)
that protects the circuit board from your fingers, and protects your fingers from
the circuit board. Parts #25-27 are mounting hardware for attaching these
handles.
Templates to make your own handle sets are available to download at:
http://www.evilmadscientist.com/go/meggyjr
Good news! The electronics part of the project is now... done!
At this point you can, if you like, put batteries in the battery box,
switch it on, and make sure that everything is working correctly.
(Please make sure the circuit board is resting on a nonconductive
surface when you apply power.)
Screw hole locations
(arrows)

[Meggy Jr RGB] [17]
STEP 15: Putting Meggy Jr in the Handle Set
Parts #26 &27 are nylon screws and acorn nuts
These parts are used to attach the upper and lower shell of a
handle set. Use no tools with these! Hand tighten, only as much
as needed, by turning the acorn nut. Over-tightening could easily
crack the plastic of the handle set.
Mounting the handle set
The top shell of the handle set (the carapace) fits neatly over the
LED display, with cutouts for the speaker, buttons, and screw holes.
Drop the four nylon screws through the screw holes to help index
the lower shell.
The lower shell (the plastron) fits on the bottom side with cutouts
for the battery box, the battery box wires, as well as the optional ISP
connector and power jack. Use the nylon screws from the top side
to help guide the lower shell into place, and secure it in place --
gently-- with the nylon acorn nuts.
“Basic handles” shown; other
types mount the same way.
Screw hole locations
(arrows)

[Meggy Jr RGB] [18]
STEP 16: Mounting the battery box with velcro
Part #28, the last part, is an adhesive Velcro strip
A strip of velcro with high-strength adhesive is provided to attach
the battery box to the back side of the Meggy Jr circuit board.
And done!
Velcro strips in place!
Before adding the Velcro...
(1) Test your Meggy Jr to make sure
that it’s working correctly,
(2) Trim very short the leads of components that
stick up where the velcro will go, and
(3) Figure out exactly where you’ll be routing the
battery box wires.
If you have not shortened the leads from the battery
box, you can route them under the velcro as shown to
take up some of the slack and provide strain relief.
When you are ready, attach the hook side of the velcro
to the battery box-- the side without the switch-- and the
loop side to the circuit board.

The hardware and software designs used in this project are
being released under an open-source license. For more
information, please see:
http://www.evilmadscientist.com/go/meggyjr
Example firmware is available for download, and your code
contributions, handle designs, and games are welcome too--
we’d love to see what you can do with it! Productive hacking
is strongly encouraged. :)
An open-source project
If you have interesting pictures or video of things built using this kit
or the hardware or software designs, we’d love to see them in the
Evil Mad Science Auxiliary:
http://www.flickr.com/groups/evilmadscience/
Got pictures?
[Meggy Jr RGB] [19]
STEP 17: Wrapping it up!
Need help?
If you encounter difficulty with Meggy Jr RGB in hardware,
software, or elsewhere, odds are that somebody knows how to
help you out. Your first stop should be the Evil Mad Scientist
Laboratories forums:
http://www.evilmadscientist.com/forum/
Programming Meggy Jr RGB
Meggy Jr RGB can be programmed through the Arduino
development environment (available at http://arduino.cc/ ), for
which we recommend using the USB-TTL cable from Step 1.
This cable connects to J2 as shown at right, with the green-
wire end to the side marked “GRN” on the circuit board and the
black-wire end to the side marked “BLK” on the circuit board.
An Arduino environment library with example code is available,
or-- if you want to start from scratch, you can start by looking at
the circuit diagram and go from there.
The ATmega168 microcontroller can also be programmed
through a standard AVR ISP programmer and the AVR-GCC
toolchain, if you would rather go that way.
Table of contents