## Introduction: Second Degree Equation Solver With Arduino

This instuctable is about making sort of a calculator that enables the user by using an analog 12-digit keyboard and 4 buttons to input the a,b,c variables into a equation and get the solution for it if there is any.(well if u don't know what an second grade equation is probably u haven't been in high school, even though you can follow this post to learn about microcontrollers.)

It can be a great electronics class project or an microcontroller starter project.  for your own use.

## Step 1: Parts List

arduino board....................http://www.oomlout.co.uk/arduino-duemilanove-p-185.html £24.17
LCD Display (16 x 2)...........................http://www.oomlout.co.uk/lcd-display-16-x-2-p-212.html £7.15
4 buttons................................................................................................................\$1.00-0
1 potentiometer.....................................................................................................\$1.00-0
16x 500ohm, 4x 1k, 1x 6k resistors .................................................................\$2.00-1
3 green LEDs.........................................................................................................\$0.25-0
lots of jumpers or striped wires  ........................................................................\$1.00-0

And patients!!!!!!

tip: if u don't have any of this parts it is highly recommended you buy an arduino starter pack that will include almost every electronic part needed, like potentiometers, wires, leds and maybe an lcd. a good one, which i bought ,is http://www.oomlout.co.uk/starter-kit-for-arduino-ardx-p-183.html

As for the tools, a soldering iron and a wire striper and cutter should be enough.

## Step 2:

The first thing u have to built is the analog keypad.I will not get into every detail as there is already an instuctable which i followed to make it. https://www.instructables.com/id/Analog-Keypad-Backpack/

I made it using 500ohm resistors instead of 1k and instead of the 12k resistor a 6k one.(u may want to use this values to have the best chances that the code works without a single variation.I also did not used a stripboard  soldered directly onto the keypads pins which is fairly easy, also i used 2 12k resistor in parallel because i didn't had any 6k at the time.
The resistors needed for this step are 12x 500ohm and one 6k

## Step 3: Puting the Bread Board Together

First connect the lcd according to the picture the pins used are 2,3,4,5,11,12 .

Then connect the potentiometer and place a jumper to the lcd as shown.

For the buttons and the leds i propose you to follow the way i placed them.

The leds are connected to pins 15, 16, 17, 18 which in fact are the analog pins A1, A2 ,A3 , A4 and the first three indicate if you have stored a number in the variables a,b,c and the last is the go indicator for the arduino posses the data given and solve the equation.

The buttons are connected  to pins 6, 7, 8, 9 . the first three  when pressed store the given value to the variables a, b, c and the last signals the arduino to solve the equation.

The last part which needs to be connected apart from the resistors is the keyboarded  that has 3 wires, the the red and the black go to the 5v and the ground. as for the last wire it goes to the analog pin 0. ( A0 )

## Step 4: The Code

Now for the most important part, the arduino code

All u have to do is to copy and upload it into your arduino and hopefully it should work fine.

The most possible malfunction is that the keyboard may not respond properly. To fix this problem what u have to do is to press the buttons on the keypad one by one and check through the serial display the outputValue1.Then in this form u have to change the numbers (1, 11, 21 ,27......)
if (outputValue1 > 1){
if (outputValue1 > 11){
if (outputValue1 > 21){
if (outputValue1 > 27){
if (outputValue1 > 33){
if (outputValue1 > 38){
if (outputValue1 > 41){
if (outputValue1 > 45){
if (outputValue1 > 47){
if (outputValue1 >= 52){
if (outputValue1 > 54){
if (outputValue1 > 56){
if (outputValue1 > 59){s1 =100;}

so when i pressed  the keys i got the numbers:
9, 16, 25, 30, 35, 40, 43, 46, 51, 53, 55, 58, 90
and i put middle numbers like  1, 11, 21, 27.....
if u do the same with the numbers that u are getting it should be easy to fix this.

## Step 5: Using It

What you need to do first (after plugging it in of-course) is to insert values a, b, c.
To do this you must first insert the value through the keypad and then press the corresponding button to insert that value into the right variable,( the # button is used to make the number negative so to insert -12 you must press 1, 2, #)  then pres the * button to get back to 0 and program the next variable

Last press the go button and the lcd will show the solution (if the equation has no solution it will display 'impossible' and if every number is a solution it will display 'indefinite'.)
( i don't know if impossible and indefinite is the accurate word to use, please leave a comment and tell me which words should i use.)
Also wait for the video of its operation.

That's it! Now go and make one yourself and have fun with it....
if u liked my instuctable, please rate it and vote for me in the microcontroller contest (https://www.instructables.com/contest/micro2/?show=ENTRIES ). Also if u have any question feel free to write a comment as i am going to be answering.

Participated in the
Microcontroller Contest