# DinoCalc Version 1.0

14,605

17

7

Published

## Introduction: DinoCalc Version 1.0

(Arduino Pro Mini Protoboard Version)

Development:      https://github.com/WeaselJones/DinoCalc

This is a calculator without a LCD that tells you if your math answer is right or wrong, without giving you the answer.  This instructable will show you how to make this simple math checking calculator using "off-the-shelf" items.

[UPDATE:  A TUTORIAL SHOWING HOW TO CREATE YOUR OWN CUSTOM INLAY GRAPHIC IS NOW INCLUDED! ALONG WITH A NEW GRAPHIC FOR GIRLS TO USE INSTEAD OF THE DINOSAUR.  CHECK OUT APPENDIX A AND B AT THE END OF THIS INSTRUCABLE!]

When I was younger I had a calculator that did not have a LCD display but instead had two LED lights, one green and one red.  You would enter a math problem with what you thought the correct answer was.  If your math problem was for example, 12 + 12, you would enter on the keypad:  12+12 = 24, and then press the "?" key.  If your answer was right then the green LED would light up, if your answer was wrong, the red LED would light up.

This is my salute to that toy from my childhood, as well as a great way for me to engineer and program a neat little project that my preschool son can actually use to check his simple math.

This first version will document the prototype that I have built. My first objective was to create a calculator capable of just adding and subtracting using off the shelf items. I plan on starting with an Arduino Pro Mini for the developmental and prototype stage and  I will then move on to a final version that has a lower cost and device count (ATmega328P on a custom PCB).

The way the calculator will work is:

1) User enters:
a Number, (for example, 12)
then a math operator, (let's pick addition, +)
then a Second Number, (let's add 13 to our first number)
then press the equal sign, (=)
then the user enters what he (or she) believes the answer to be, (let's guess 22)
then press "?" to see if you're right or wrong!

2) Microprocessor then calculates the correct answer.
In our case, 12 + 13 = 25. So the Calculated correct answer is 25.  This answer is just
stored in memory and not shared with the user.

3) Microprocessor compares the calculated answer to the user's
If they are not equal then the microprocessor turns on the red LED.
If they are equal then the microprocessor turns on green LED.
We guessed 22, so 22 is not equal to 25 so the RED LED LIGHTS UP!

Notes and Limitations:
1) Only one math operation is currently supported (ie, 12+12 or 12 - 12 will work, but 12+12+12 or 12+12-12 will not)

2) Negative numbers will work (ie, -12 + -12 or -12 - -12 will work)
3) Large numbers will work (ie, 123456789 + 8765 will work)

4) Decimal Numbers will work (ie, 12.1 +12.2 will work)
5) I made this for my preschool son, so right now the only math operators currently supported is addition and subtraction.  Multiplication and Division will be easy to add in the near future.
6)  The last limitation is your imagination.  Just because I did something one way, don't be afraid to change it to work for you!

TIP:  TO COMPLETE THIS PROJECT THE BUILDER WILL NEED TO HAVE EXPERIENCE WITH SOLDERING AND USING THE ARDUINO IDE. THERE ARE MANY TUTORIALS ON USING THE ARDUINO IDE ON INSTRUCTABLES AND AT HTTP://ARDUINO.CC.  IF YOUR EXPERIENCE IS LIMITED, I RECOMMEND BUILDING THIS PROJECT FIRST ON A BREADBOARD, AS SHOWN IN THE OPTIONAL STEP 5, SO THAT THE BUILDER CAN BECOME MORE FAMILIAR WITH THE DINOCALC SOFTWARE AND PROGRAMMING OF THE ARDUINO PRO MINI.
AND WHILE THIS PROJECT ISN'T COMPLICATED TO SOLDER
YOU MIGHT NOT WANT THIS TO BE YOUR FIRST SOLDERING EXPERIENCE.  IF YOU'VE NEVER SOLDERED BEFORE THERE ARE MANY "LEARN HOW TO SOLDER KITS" THAT YOU CAN PRACTICE AND LEARN ON FIRST.  SUCH AS:  Elenco AmeriKit Learn to Solder Kit.

## Step 1: "How Do You Eat an Elephant?"

TIP:  Even a small project can be overwhelming and risks not being finished if you try and do too much at once.  Instead, establish some goals and guidelines and work to meet them one step at a time.  You'll feel better after each achievement and it helps to prevent your project from winding up in some storage box unfinished.

We've all heard the question about eating an elephant one time or another and we know the answer, "One bite at a time".

I have often been guilty of starting a project and then placing the unfinished project into a box or on a shelf to collect dust because either I hit a "road block" or just overwhelmed myself with trying to do too much at once.  I often try to eat the Elephant in one bite.

This time I decided to try a different approach (plus I promised my wife I'd actually finish something this time).

So first I set a series of goals for my project and I decided to stick to them.  I then divided all my goals into two main groups: Software and Hardware.   When I found time to work on my project I'd focus on one goal and try not to get distracted.  If I came up with an idea that belonged with another goal, I'd write it down so I could revisit my idea when I was working on that particular goal.  If it was an idea that would be nice to have but really belonged in a future version (ie, custom etched PCB board, low power mode, battery recharging, etc) I would write it down in my notebook under "Future Objectives".  This way I didn't overwhelm myself by making my project so large that it would never stop growing and never get finished.  My notebook held my project together.

I highly recommend you too keep a notebook to jot down your experiments, references, and even your failures.  I've learned a lot, even from my failures. Success consists of going from failure to failure without loss of enthusiasm. --Winston Churchill

HARDWARE
1)  Needs to be able to be set up on a breadboard for the software development phase
I started with a keypad, Arduino Uno, and some LED's.  I used this breadboard setup until my code was finished.
2)  What is used during development needs to be easily translated into a prototype product
I needed something smaller then the Uno and the Arduino Pro Mini fit the bill.  I could use my program I developed on the Uno and the Arduino Pro Mini would be small enough to fit in the "Sparkfun" enclosure I was looking at.  I thought about custom etched PCB with just a low powered ATMega328P but decided to stick with my original goals of using "off the shelf" items and save the custom PCB for a future version.
3)  Needs to be easy to hold and operate by 4 yr old fingers
I searched many different enclosures and was about to settle on using the "Sparkfun" enclosure when I can across the Hammond enclosure with battery holder.  It was exactly what I envisioned.
4)  Needs to be appealing in appearance so the 4 yr old wants to use it
My son loves hot wheels, lizards, and dinosaurs.  So I searched around until I found a dinosaur face that would scale easily to the front of the hand held enclosure.  Image was found at:  http://www.arthursclipart.org/dinosaurs/dinosaurs/page_02.htm

SOFTWARE
1)  Needs to be able to detect button presses from a keypad
First goal, I needed to be able to tell which button was being pressed.
2)  Needs to be able to input the button presses into variables
I then needed to have my program store my button presses.  I needed to be able to use numbers larger than just single digits.
3)  Needs to be able to perform addition or subtraction (multiplication and division can come later, since my son is only 4 yrs old)
Having my program know when to add or subtract became a challenge.  And this then became a major challenge when I decided to include negative numbers. If I hadn't broke my software code development into "smaller" bites, this could have been the "road block" that would have killed this project.  I did add decimal numbers to the programming so that when I do add division it will already be there.
4)  Needs to be able to calculate the correct answer and then compare it to the guessed answer the User inputs
This goal led to my discovery about the limitation of floating number math which was solved by comparing the absolute value of the difference between the correct answer and the guessed answer.
5)  Needs to be able to respond to the user with either a correct or incorrect response.
Light the Red LED for wrong; Green LED for right.

So now that you know the approach I took, lets get started on building your DinoCalc!

## Step 2: Bill of Materials

Here is a list of what is needed to put together your calculator with "off the shelf items". No etching required (I'm saving that for a future version).

I looked up part numbers for this project on Mouser.com and Sparkfun.com.  You'll need parts on both lists.  At least half of the components I used came from an electronic spare parts bin I've been building up ever since I started my hobby.  If you also have a parts bin, then just adjust both lists to your situation.

TIP:  Part of the fun of doing a project like this is making it yours!
If you can't find everything or if you think, "Hey, what was this guy thinking?  Part XYZ will work better!"  Then please feel free to use different parts or even different suppliers. If you hate AVR then just modify the project and software code so you can use your favorite microprocessor, like a PICAXE.  I'm releasing all my source files and it won't hurt my feelings if you change things. But please do make sure to share what you came up with!

DinoCalc Hardware version 1.0 Bill of Material
(Arduino Pro Mini Protoboard Version)

-------------------------------------------------------
MOUSER.COM
-------------------------------------------------------
Item
No.   Qty   Description                                                              Part Number
--    ---   -------------------------------------                                     ----------------
1)     1    9v Alkaline Battery                                                    658-6LR61XWA
2)     1    CARBON FILM RESISTOR - 330 OHMS                   291-330-RC
3)     1    CARBON FILM RESISTOR - 270 OHMS                   291-270-RC
4)     1    SPST ON-OFF SLIDE SWITCH                                 112-R13-602A
5)     1    LED - THROUGH HOLE GREEN DIFFUSED             78-TLHG5400
6)     1    LED - THROUGH HOLE RED DIFFUSED                  78-TLHR5400
7)     2    5MM LED PANEL MOUNTING                                   696-SSH-LX5091
8)     1    4X4 MATRIX MEMBRANE KEYPAD                           619-27899
9)     1    PROTOTYPE BOARD FOR 1553DBKBAT ENC        854-PR1553DBAT
10)   1    HAND HELD ENC WITH BATT COMPARTMENT      546-1553DBKBAT

You can also find this Bill of Material on the mouser.com website under the DinoCalc version 1.0 project at the following link:

http://www.mouser.com/ProjectManager/ProjectDetail.aspx?AccessID=0904c64079

----------------------------------------------------
SPARKFUN.COM
----------------------------------------------------
The following is a list of parts needed for this project on sparkfun.com.

Item
No.  Qty   Description                                                 Part Number
--    ---   -------------------------------------                        ----------------
1)     1    Arduino Pro Mini 328 - 5V/16MHz               DEV-11113
2)     1    FTDI Basic Breakout - 5V                            DEV-09716  (Optional)
3)     1    Female Headers                                          PRT-00115  (Recommened)
4)     1    Break Away Headers - Straight                   PRT-00116
5)     1    Break Away Male Headers - Right Angle    PRT-00553
6)     1    Solderless Headers - 10-pin Straight          PRT-10527  (Optional)
7)     1    Jumper Wire - PTH Black White                 PRT-08672  (Optional)
8)     1    Jumper Wire - 0.1", 3-pin, 6"                       PRT-10368  (Optional)
9)     1    Hook-up Wire - Red                                     PRT-08023  (Optional)
10)    1    Hook-up Wire - Black                                 PRT-08022  (Optional)

Notes:
Item #2:  This is needed only if you don't already have a way to program the Arduino Pro Mini.
DEV-09718 5V FTDI Cable will also work and you won't need to find a USB Cable.
Item #3:  This is recommended so that you don't make the Arduino Pro Mini a permanent installation
in your calculator.  You want to reuse it for a later project.
Item #6:  This can be used in place of soldering headers to the Arduino Pro Mini Programming Header.
Items #7 and #8:  These are recommended only if you don't already have some old jumper wires laying
around (such as from old CD-ROM kits or old computer boards).
Items #9 and #10:  Hook-up Wire is needed only if you don't already have a source of 22 AWG wire for
the wiring on the protoboard.

You can find this Bill of Material in a Wish List on Sparkfun.com at:
https://www.sparkfun.com/wish_lists/56143

----------------------------------------------------
AMAZON.COM
----------------------------------------------------
This was the adhesive paper purchased to place over
the keypad and on the enclosure face.

Item
No.   Qty   Description
--    ---   -------------------------------------
1)     1    Avery Sticker Project Paper, White, 8.5 x 11 Inches, Pack of 15 (03383)

----------------------------------------------------
MISCELLANEOUS
----------------------------------------------------
These are standard items you probably have on hand already:

1)  Soldering Iron
2)  Solder
3)  Heat Shrink or Electrical Tape
4)  Color Printer for printing the enclosure overlay

.

## Step 3: Preparing the Arduino Pro Mini

For the Prototype version I chose the Arduino Pro Mini 5V/16MHz.  While I developed the code for the calculator with my Arduino Uno and a breadboard, I knew that the Arduino Uno would be too cumbersome to place inside a hand held enclosure.  The Arduino Pro Mini is small and ideal for a small enclosure and compatible with the Arduino Uno, so I knew my code would need little or no modification to work with it.

The Arduino Pro Mini comes without any headers so you will need to add some yourself.  First take your male pins and separate two 12 pin sections.  These will be soldered on the sides as shown.  I used my breadboard to keep the pins lined up during soldering. For the programming header you can either solder six right angle male pins, or follow the tip below and use solderless headers for programming.

TIP:  INSTEAD OF SOLDERING A HEADER TO THE PROGRAMMING HEADER, USE "SOLDERLESS HEADERS", SUCH AS THE SPARKFUN PART PRT-10527.  THESE HEADERS ALLOW YOU TO PROGRAM YOUR ARDUINO PRO MINI AND ARE REMOVABLE AND REUSABLE WHEN YOUR PROGRAMMING IS DONE.

## Step 4: Programming the Arduino Pro Mini

Now it's time to program the Arduino Pro Mini.

FIRST:

Place the KEYPAD folder into your libraries folder of the Arduino IDE.
This library makes using a matrix type keypad easier to program.

SECOND:
Extract the zip file and inside you'll find two folders:  Hardware and Software.  Right now we're interested in the Software folder.

In the Software folder is another folder named DinoCalc.  This folder can be copied to your Arduino "sketchbook" location.
This folder contains the source code (DinoCalc.ino) and a hex file.  The hex file is for advanced users that might be using a different AVR programmer.

TIP:  If you aren't sure where your "sketchbook" location is, then open the Arduino IDE and look under File/Preferences.  You'll see where the sketchbook location is on your computer.

THIRD:
Read the Sparkfun Tutorial to become familiar with your Arduino Pro Mini, especially if you are new to "Arduino".  Even though the tutorial mentions the 3.3V version, it is still applicable to the 5V  version.  Just make sure you use the 5V FTDI programmer and select the 5V version of the Arduino Pro in the Arduino IDE when you are programming.  Also, use the latest Arduino IDE.  You don't need to download the older version shown in the tutorial.

ARDUINO PRO MINI TUTORIAL

Make sure when attaching the FTDI that the GRN label on the FTDI programmer lines up with the GRN label on the Arduino Pro Mini and that the BLK label matches the BLK label..  As long at the FTDI programmer is attached, the Arduino Pro Mini can be powered from the FTDI programmer.

FOURTH:
Open the DinoCalc.ino file with the Arduino IDE.

Press the Upload button on the IDE and after a few flashing TX RX lights your Arduino Pro Mini will be programmed!

If you have any errors, make sure you placed the keypad library in the proper place and then go back and check the Sparkfun tutorial and make sure you have everything connected right.  Also, make sure you've selected the Arduino Pro Mini 5V/16MHz under the IDE Tools/Boards Menu, and that you've selected the proper COMM port for your FTDI programmer under the Tools/Serial Port menu.

## Step 5: Testing on Breadboard (optional)

This step shows the Arduino Pro Mini setup on a breadboard.  It isn't needed to complete the project but can be used if you wish to modify the program for your own application or if you wish to program and test the Arduino Pro Mini before installing it into the enclosure.

I used an eight pin male straight header to connect the ribbon cable from the keypad to the breadboard.  The connections were as follows:

Arduino D 2 ---> 4x4 keypad pin 1
Arduino D 3 ---> 4x4 keypad pin 2
Arduino D 4 ---> 4x4 keypad pin 3
Arduino D 5 ---> 4x4 keypad pin 4
Arduino D 6 ---> 4x4 keypad pin 5
Arduino D 7 ---> 4x4 keypad pin 6
Arduino D 8 ---> 4x4 keypad pin 7
Arduino D 9 ---> 4x4 keypad pin 8
Arduino D10 ---> (long leg)RED LED(short leg) --->
330 ohm resistor ---> GND
Arduino D11 ---> (long leg)GRN LED(short leg) --->
270 ohm resistor ---> GND

The Arduino Pro Mini can be provided power from the FTDI programmer or after you've programmed the Arduino Pro Mini you can hook up a 9V battery for StandAlone Power
.
Standalone Power:
9V POSITIVE ---> Arduino Pro Mini RAW
9V NEGATIVE---> Arduino Pro Mini GND

Using the breadboard setup shown, this is how I worked on the software until it performed the way I expected.

If you are using the 4x4 membrane keypad without the sticker overlay, you can change the keypad array in the program to match the numbers on the face of the keypad.  Just remember A is plus, B is minus, C is ?, D is equals, # is decimal point, and * is C.  Also don't forget to change the code back before you apply your sticker overlay and place the Arduino Pro Mini into an enclosure.

In the program change lines 203-207 from:

char keys[ROWS][COLS] =
{{'7','8','9','+'}, //Sticker will be applied over keypad to
{'4','5','6','-'}, //match the layout I want and to provide
{'1','2','3','?'}, //a custom graphic (eg dinosaur, bird, etc)
{'C','0','.','='}};//

change this to:

char keys[ROWS][COLS] =
{{'1','2','3','+'}, //Sticker will be applied over keypad to
{'4','5','6','-'}, //match the layout I want and to provide
{'7','8','9','?'}, //a custom graphic (eg dinosaur, bird, etc)
{'C','0','.','='}};//

## Step 6: Protoboard Layout

It is now time to start placing your components onto the Protoboard that fits inside of the enclosure.

In the Hardware folder from the DinoCalc-Release-1v0.zip package that you have already downloaded, there is a folder called, EagleCad files.  Inside is a schematic called, DinoCalc_1v0_Schematic.pdf.  Also under Hardware is the folder Hardware Layouts.  Inside is a pdf called Hardware Layout Version 1v0.pdf.   You might want to print out a copy of these files and have them handy as you add components.

IMPORTANT!:  I am showing part placement on my graphic with the copper bottom of the Protoboard shown facing up.  This is to help show how everything is connected.  The copper side will be on the bottom since you will be soldering on the copper side, and the parts will be placed on the fiberglass side, as shown in the photos.

TIP:  Under the Hardware folder is another folder called Datasheets.  If you wish to modify the layout that I have, there is an Actual Sized PCB layout on the BPS-MAR-PR1553DB-001.pdf datasheet.  Just remember not to scale the pdf when you print it.

## Step 7: Protoboard Layout (Keypad Connector)

Break away 8 pins from your right angle male headers.  This will be used to connect the keypad to the Arduino Pro Mini.  Notice how the header is placed on the "two-hole" pattern.  This allows the Arduino Pro Mini to be soldered right next to the keypad connector.

Look close, you can see the pins for the right angle header right before soldering.

## Step 8: Protoboard Layout (Female Headers)

If you want your Arduino Pro Mini to be removable (which I highly recommend) then break away two twelve holed female headers and install one next to the Keypad Connector you just soldered.  Line it up so that pin 2 on the Arduino Pro Mini lines up to the first pin on the keypad.  Then place the other female header parallel and six holes away from the first female header.

If your Arduino Pro Mini will be permanently soldered into place, then wait to do it at the very end since there will be several wires under the Arduino Pro Mini.

TIP:  Seperating female headers almost always results in one pin being sacrificed.  I would cut through the 13th pin and then carefully shave off the extra plastic to give me 12 perfect female pins.  You can also use the Arduino Pro Mini to help line up the female headers while soldering.  Test fit the headers onto the Arduino Pro Mini and then line up the Arduino's digital pins 2 through 9 with the keypad connector.  Once soldering is complete you can remove the Arduino Pro Mini from the female headers so that you can solder in the wiring for the next step.

## Step 9: Protoboard Layout (Battery Connections)

TIP:  If you haven't already, you might want to print out the Hardware Layout Version 1v0 pdf and have it next to you when making these connections.

FIRST:
Take a scrap piece of bare wire, such as one snipped from a LED or capacitor, and solder across a row of the contacts, as shown.

SECOND:
Next, solder the 9V battery connector's black wire to one of the holes next to the piece of wire you just soldered.  These holes will form the Ground Bus and will be used to connect all of the grounds (LED, Arduino Pro Mini, Battery).

THIRD:
Solder a two pin right angle male header, and attach the positive wire of the 9V battery connector to one side as shown.  This male header is where the SPST switch will enable or break the power from the 9V battery.  Connect the other side of the male header with a wire to where the RAW pin on the Arduino Pro Mini will be.  Optional:  A diode can be place between the positive wire of the 9V battery connector and the SPST switch header.  This would help protect your circuit from a battery being inserted backwards.  I chose not to use a diode here since I'd be the only one changing out the 9V battery and the connector will only fit one way onto the 9V battery.

FOURTH:
Solder a wire from next to the female header where the GND on the Arduino Pro Mini will be (this wire will be underneath the Arduino Pro Mini) and solder it to the Ground Bus.

FIFTH:
Solder in place a three pin right angle male header as shown for the LED lights.

WAIT A MINUTE, you said THREE PIN and you show FOUR pin, WHAT's UP???  You are 100% right, I am showing a four pin header with one pin snipped off.  What I used for a cable was from an old CDROM kit.  It has a four pin connector with only three wires.  Only three wires will be needed to connector your LED lights.  If you only use a three pin connector with three wires, then feel free to modify what I am showing to just a three pin right angle connector.

SIXTH:
Solder the LED connector's ground to the Ground Bus.

## Step 10: Protoboard Layout (LED Connections)

And last but not least solder the wires to finish connecting the LED header to the Arduino Pro Mini as shown.

Arduino digital pin 10 ---> Red LED
Arduino digital pin 11 ---> Green LED

WAIT A MINUTE!  Where are the resistors for the LED Lights!
That's a great observation!  We'll be soldering the resistors directly to the LED lights and mount them in the enclosure lid in an upcoming step.

## Step 11: Print Your Inlay Graphic

From your Hardware Folder, under DinoCalc Inlays, print the file:  Enclosure Front Inlay T-Rex.pdf onto adhesive backed paper.

TIP:  WHEN PRINTING, MAKE SURE YOU SELECT "ACTUAL SIZE" IN YOUR PDF VIEWER INSTEAD OF ANY "FIT TO PAGE" OR "SCALING" OPTIONS.  THE INLAY HAS BEEN MADE TO FIT THE SUGGESTED ENCLOSURE'S EXACT DIMENSIONS.

[UPDATE:  See APPENDIX A at the end of this instructable for a graphic inlay that can be used in place of the dinosaur.  Also, APPENDIX B is a short tutorial I wrote showing how you can use the Inkscape files I provided to make your own custom graphic!]

## Step 12: Apply the Inlay Graphic to the Enclosure Top

Carefully cut out the dinosaur face from the adhesive backed paper.  Peel back a small piece of the backing and adhere the graphic to the inlay pocket on top of your enclosure.  Next, carefully smooth your graphic down as you peel off the rest of the backing.  Remember to take your time.  The adhesive paper I recommend is a little forgiving, but not by much.

Next, carefully cut out the keypad overlay from your adhesive paper.  Peel back your backing and carefully smooth the adhesive paper down on to the keypad using something like a credit card.  This will help prevent air bubbles and will make sure your paper adheres between the slightly raised buttons on the membrane keypad.

IMPORTANT!:  DO NOT ADHERE THE KEYPAD TO THE ENCLOSURE AT THIS TIME! DO NOT REMOVE THE PAPER BACKING ON YOUR "MEMBRANE KEYPAD".  YOU STILL NEED TO CREATE A HOLE IN THE ENCLOSURE'S TOP FOR THE RIBBON CABLE IN A LATER STEP.

## Step 14: Graphic Applied to Enclosure and Keypad

You now have your graphic applied to your enclosure and Keypad. The lines on the Enclosure graphic are where you will line up your keypad in a future step.

## Step 15: Drilling Holes for Eyes

Now drill a couple of holes for your LED's using a quarter inch drill bit.  Carefully clean any paper bits from the holes.

TIP:  USE AN AWL OR A NAIL AND HAMMER TO TAP A TINY INDENTATION IN THE CENTER OF WHERE YOUR HOLE WILL BE.  THIS INDENTATION WILL HELP HOLD OUR DRILL BIT AND KEEP IT FROM "SKIPPING" ACROSS YOUR ENCLOSURE.

## Step 16: Measure Position of Keypad Cable

Turn your membrane keypad over.  Measure the distance the ribbon cable is from the bottom of keypad and measure the width of the ribbon cable.

Mark off a spot where you'll cut a slot for the ribbon cable.

On your enclosure lid from your bottom line mark off a vertical line on each side of the center that is a little bigger than half your ribbon cable width.  This will center the ribbon cable and give a little wiggle room.

Next, measure up from the bottom line the measurement you took on the location of the ribbon cable from the bottom of the keypad.  Mark a couple of horizontal lines above and below your distance.  The lines should be about 1/4 in apart.

## Step 17: Drill Slot for Keypad Cable

Using your quarter inch drill bit, drill about 4 holes side by side in rectangle you marked off.

## Step 18: Smooth the Drilled Holes Into a Slot

Using your rotary tool (Dremel) finish smoothing out the edges for your slot.

## Step 19: Test Fit the Keypad Cable

Don't remove the paper backing from your keypad yet.  Do a quick test fit to make sure the keypad ribbon cable will slide into the slot when the keypad is aligned properly with the enclosure lid.

## Step 20: Attach Keypad to Enclosure

Now remove the paper backing from your keypad.  Carefully slide the ribbon cable through the slot and alight the keypad to match the graphic on the enclosure lid.  Press down and hold a few seconds.

## Step 21: Resistors for the LED Lights

If you purchased the Vishay LED's I show in the Bill of Materials they are rated as follows:

Green LED:  Forward Voltage (Vf) = 2.4V, Forward Current (If) = 10mA = 0.010A
Red LED:  Forward Voltage (Vf) = 2.0V, Forward Current (If) = 10mA = 0.010A

To Calculate the size Resistor Needed:
R (ohm) = (Volts (V) - Forward Voltage (V)) / (Forward Current (Amps))

For the Green LED:
R = (5V - 2.4V) / (0.010A)
R = 260 Ohms
or sizing to the closest resistor value:  270 Ohms

For the Red LED
R = (5V - 2.0V) / (0.010A)
R = 300 Ohms
or sizing to the closest resistor value:  330 Ohms

If you are using different LED's then substitute your data from your LED datasheet and calculate the resistors you'll need to use.

## Step 22: Solder LED and Resistor

For both LED's:

Twist together the wire from one side of the resistor (doesn't matter which) and the LED wire from the "CATHODE" side of the LED (the side with the flat mark and the short leg).

Place a piece of heat shrink over the resistor and new solder joint.  Shrink with lighter or heat gun.

TIP:  WHEN DELICATE PARTS MIGHT BE EXPOSED TO EXCESSIVE HEAT, USE A COPPER ALLIGATOR CLIP.  THE COPPER CLIP ACTS AS A HEAT SINK AND WILL TAKE THE HEAT AWAY FROM YOUR COMPONENT.

## Step 23: Insert LED Holders

Insert the LED Holders into the holes you had drilled earlier.

## Step 24: Insert LED's

Insert each LED into a holder.  They will click into place.

## Step 25: Connect the LED's Cathodes Together

Twist the "CATHODE" ends of the LED's together, but do not solder yet.

## Step 26: Prep Jumper Wire

From your three wired Jumper, strip off at least half an inch of insulation on each wire and then tin your wire.

Next, slide on a piece of heat shrink for later.  Make sure it is out of the way when you solder so that it doesn't shrink prematurely.

TIP:  Save your old jumpers from old CD-ROM kits.  They can be cut in half for "two" three wire or two wire jumpers!

## Step 27: Solder Jumper to LED's

Solder your wires to the LED's.  Make sure the heat shrink sleeve stays out of the way.

In my case:
Black to Cathodes
Red to Red LED anode
White to Green LED anode

After soldering each wire, slide the heat shrink down and shrink to cover any exposed wire as shown.

## Step 28: Create a Hole for Switch

Before you remove the front panel piece from your enclosure, make sure your switch  will clear the Protoboard when it is installed and mark off a spot.

Next, create a hole that will just fit your switch.  I did this by drilling a couple of small holes and then using my rotary tool (Dremel) to widen it into a small rectangle.  Just like what was done making the slot in the enclosure lid for the keypad ribbon cable.

I then used a small drill bit and drilled a couple of tiny holes through the holes on the switch.  I found a couple of tiny screws in my old computer part bin, I think they are M3-0.50 screws, and made sure not to over tighten them.  They hold the switch in quite nicely.

Another way this can be done is to use two small machine screws and bolts or maybe even hot glue on the inside of the panel to hold your switch in place.

## Step 29: Solder Cable to Switch

Using your two wire jumper, slide a piece of heat shrink onto the wire.

Solder one wire to one connector and then slide the heat shrink down to the switch and shrink.

You will now be able to turn off your DinoCalc when it is not being used!

## Step 30: Attach Switch Cable to Protoboard

Slide the switch jumper onto the two Power Pins.

Place the faceplate with the switch back in its groove at the front of the enclosure.

Insert your Arduino Pro Mini (or solder into place if you decided not to use the recommended female headers)

## Step 31: Attach LED Cable to Protoboard

Apply some tape to help hold the LED connections to the lid.

Screw down your protoboard with the provided screws.

Remove the battery cover from your enclosure bottom.

Replace your front panel with the power switch into the enclosure groves and then attach your Keypad to its pins.  Make sure the battery connector is hanging out the battery compartment.

## Step 33: Pinch the Case Together

Double check your front panel to make sure it is in its groove and you see the battery connector in the battery compartment.

Once you have the case closed without any pinched wires, screw the enclosure together with the provided screws.

## Step 34: Finishing It Up

Connect a 9 V battery to the battery connector and place the battery cover on the back of the enclosure.

If you get in a bind, Press the "C" button to clear the calculator's memory and start your problem over.
And if you make a mistake, like pressing the equal sign key twice, the Red LED will rapidly blink and clear the memory.

To enter a math problem:

1) User enters:
a Number, (for example, 12)
then a math operator, (let's pick addition, +)
then a Second Number, (let's add 13 to our first number)
then press the equal sign, (=)
then the user enters what he (or she) believes the answer to be, (let's guess 22)
then press "?" to see if you're right or wrong!

2) Microprocessor calculates the correct answer
In our case, 12 + 13 = 25. So the Calculated correct answer is 25.

3) Microprocessor compares the calculated answer to the user's
guessed answer.  If they are not equal then light up the red LED.  If they
are equal then light up the green LED.
We guessed 22, so 22 is not equal to 25 so the RED LED LIGHTS UP!

Notes and Limitations:
1) Only one math operation is currently supported (ie, 12+12 or 12 - 12 will work, but 12+12+12 or 12+12-12 will not)
2) Negative numbers will work (ie, -12 + -12 or -12 - -12 will work)
3) Large numbers will work (ie, 123456789 + 8765 will work)
4) Decimal Numbers will work (ie, 12.1 +12.2 will work)
5) I made this for my preschool son, so right now the only math operators currently supported are addition and subtraction.  Multiplication and Division will be added in a future software update.
6)  The last limitation is your imagination.  Just because I did something one way, don't be afraid to change it to work for you!

TIP:  Make sure you turn off your DinoCalc when not using it, so that you don't run down your battery!

## Step 35: Educational Material

A quick google search on "Simple Math Problems" turns up a wealth of worksheets for your aspiring math genius.

You can also just create your own.  Just remember the limitations and that the software currently only supports addition or subtraction of two numbers.

UPDATE:  Check back soon for a software update that will allow more than two numbers.

## Step 36: Future Features/Improvements

TIP:  Make sure you turn off your DinoCalc when not using it, so that you don't run down your battery!  The current circuit uses 13.78mA just sitting idle.

Future objectives (not in any particular order) will be to:

1) Replace the Arduino Pro Mini board with a custom made PCB and reduce parts to a minimum to lower costs (I already have several friends wanting versions for their kids)

2) Add multiplication and division to the calculator's capabilities (low priority for me since this will involve more keys then a 4x4 matrix keypad and my son is only starting addition and subtraction right now)

3) Develop a custom keypad (maybe using tactile buttons and caps, or making my own "membrane" type keypad, or exploring "conductive" type buttons)

4) Add sound for errors or beep whenever custom keypad button is pressed

5) Develop code so that it could also be used for a "math" type game for multiple players. For example, Display a math problem and contestants enter answer on their calculators. If their answer is right, their token moves away from some peril (like a chomping dinosaur) and if wrong moves closer to peril. Loser is the one that gets eaten (chomp,chomp,chomp)

6) Make the circuit low-power for longer battery life and replace the 9V battery with two NiMH AA batteries or perhaps even a “button” cell rechargeable battery.

7) Add a recharging circuit to recharge the rechargeable batteries from USB

8) Try laminating or covering the graphic inlay with contact paper to protect the DinoCalc from sticky fingers.

## Step 37: REFERENCES

References used during development:

1)  http://tronixstuff.wordpress.com/tutorials  > Arduino Tutorials, chapter 42a, Keypads II

2)  http://www.arduino.cc/playground/Code/Keypad by Mark Stanley,  Alexander Brevig

3)  "Arduino Cookbook", 2nd edition, by Michael Margolis, O'Reilly Media, Inc.

4)  "BlinkWithoutDelay" example by David A. Mellis and Paul Soffregen that came with Arduino IDE 1.0.3

5)  Floating number math with Arduino,   http://arduino.cc/en/Reference/Float

## Step 38: APPENDIX A: NEW GRAPHIC INLAY FOR DINOCALC

Here is a bonus graphic!

Instead of two LED's, this overlay can use one common cathode Red/Green LED (or a common cathode RGB LED) without needing to modify the hardware configuration or the software.

COMMON CATHODE
Calculate your resistors for red and green anode based on your datasheet and then just wire as shown for the two LEDs, except:
1) Connect common cathode to ground.
2) Attach the wire for the Red LED to output 10 and then to the Red's resistor and Red anode
3) Attach the wire for the Green LED to output 11 and then to the Green's resistor and Green anode

If you have a common anode Red/Green or RGB, then you will need to do some modifications.

COMMON ANODE
1) Connect the common anode to the VCC pin for 5V (not to RAW or to the battery).
2) Calculate your Red resistor and attach to your LED's Red pin cathode and then wire to output 10
3) Calculate your Green resistor and attach to your LED's Green pin cathode and then wire to output 11

You'll also need to modify the program.  Go through and change anywhere the program calls for outputs 10 and 11:
4) When you want the LED to be Green then the Red output is HIGH and the Green output will be LOW.
5) When you want the LED to be RED, the Green output will be HIGH and the Red output will be LOW.
6) When you want the LED to be off you will have the Green output HIGH and the Red output HIGH.

## Step 39: APPENDIX B: Make Your Own DinoCalc Inlay Tutorial

You have a graphic you want to use?

Here's a tutorial showing how you can use the Inkscape files I've provided you to create your own graphic inlay.

If you share your inlay, I'll add it into the next release (as long as it is still "preschool" appropriate and not rude, crude, or obscene).

## Step 40: Finale

If you choose to build this project or your own variation, I hope you have as much fun as I did.

Best wishes.

## Recommendations

• ### Arduino Class

69,093 Enrolled

• ### Microcontroller Contest

We have a be nice policy.

## Questions

I want to modify this to do multiplucation/division. Any idea on where to get started?

Also, on Github under the "Software: multiple operand" branch I was working on a way to allow multiple operands (like 1+2-3+4-5). I started using arrays to keep track of the calculations but I haven't placed anything for "order of operations" that you'll need when you multiply or divide. My job has been keeping me away from my hobbies so it isn't finished, but you're welcome to look at it.

this is brilliant. I'm not confident that I would be patient enough to do this, but I would definitely buy one for my youngest son. You should market this.