Sandibell Vega Final Project

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

Sandibell Vega

Overview / Purpose of Project


● Project Goals

The project goals where It can give a calculation to the user and provide the answer. It
creates a project where a chatbot mathematics responds with your math problem.
Where it displays the using a LCD and Keypad with Arduino uno where help to solve
like a calculator. Just learn how to do a calculation this helps learn the basic
programming and the functions of LCD with the Keypad.

● Project Implementation
○ Schematics

■ Bill of Materials (Listing of all components utilized in your


project)

LCD x1

Arduino uno x1

Keypad x1

Wires x 24
Potentiometer x1

Resistor x 1

○ Hardware Design
■ Mechanical Drawings

○ Software Design
■ Code listing with user’s guide

#include <LiquidCrystal.h>
#include <Keypad.h>

LiquidCrystal lcd(13, 12, 11, 10, 9, 8); // setting the expander


address, number of lcd columns, number of lcd rows

long first = 0;
long second = 0;
double total = 0;
int posit = 0 ;
char customKey;
const byte ROWS = 4;
const byte COLS = 4;

char keys[ROWS][COLS] = { // keypad equivalents


{'1','2','3','/'},
{'4','5','6','*'},
{'7','8','9','-'},
{'C','0','=','+'}
};
byte rowPins[ROWS] = {7 ,6 ,5 ,4}; // connecting rows from keypad
toward Arduino
byte colPins[COLS] = {3, 2, 1, 0}; // connect columns from keypad
toward Arduino

Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins,


ROWS, COLS); // class Keypad instance initialization

void setup(){
lcd.begin(16,2);
lcd.setCursor(5,0);
lcd.print("Hello, my ");
lcd.setCursor(3,1);
lcd.print("name is UAT");
delay(3000);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("Basic Calculator");
lcd.setCursor(4,1);
lcd.print("Arduino");
delay(2000);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("I'm a Chatbot");
lcd.setCursor(4,1);
lcd.print("that loves Math");
delay(1000);
lcd.clear(); //clears the LCD screen and positions the cursor in
the upper-left corner.
}
void loop()
{
customKey = customKeypad.getKey();
switch(customKey)
{
case '0' ... '9': // get first value for calculation
lcd.setCursor(0,0);
first = first * 10 + (customKey - '0');
lcd.print(first);
posit++;
break;

case '+':
first = (total != 0 ? total : first);
lcd.setCursor(posit,0);
lcd.print("+");
posit++;
second = SecondNumber(); // get second number
total = first + second;
lcd.setCursor(1,1);
lcd.print(total);
first = 0, second = 0; // reset the values
posit=0;
break;

case '-':
first = (total != 0 ? total : first);
lcd.setCursor(posit,0);
lcd.print("-");
posit++;
second = SecondNumber();
total = first - second;
lcd.setCursor(1,1);
lcd.print(total);
first = 0, second = 0;
posit=0;
break;

case '*':
first = (total != 0 ? total : first);
lcd.setCursor(posit,0);
lcd.print("*");
posit++;
second = SecondNumber();
total = first * second;
lcd.setCursor(1,1);
lcd.print(total);
first = 0, second = 0;
posit=0;
break;

case '/':
first = (total != 0 ? total : first);
lcd.setCursor(posit,0);
lcd.print("/");
posit++;
second = SecondNumber();
lcd.setCursor(1,1);

second == 0 ? lcd.print("Error") : total = (float)first /


(float)second;

lcd.print(total);
first = 0, second = 0;
posit=0;
break;

case 'C':
total = 0;
first = 0;
second = 0;
posit = 0;
lcd.clear();
break;
}
}

long SecondNumber()
{
while( 1 )
{
customKey = customKeypad.getKey();
if(customKey >= '0' && customKey <= '9')
{
second = second * 10 + (customKey - '0');
lcd.setCursor(posit,0);
lcd.print(second);
}
if(customKey == 'C') {
total = 0;
first = 0;
second = 0;
posit = 0;
lcd.clear();
break;
}

if(customKey == '='){
lcd.setCursor(0,1);
lcd.print("=");

posit = total;
lcd.clear();
lcd.setCursor(0,1);
lcd.print("=");
break;
}
}
return second;}

● Development Issues
○ Any problems / difficulties you encountered during development

There are some difficulties I have encountered during development however I solve it by
going with my code. I changed my project instead to an emotional chatbot to calculate
where users can get the answer to the problem. Beside that I had fun learning and to be
exposed toward this project.

○ Solutions to problems / difficulties

The solutions to the problems change the project and go over my code when I run
difficulties. Designing the circuit but I just had to figure it out and had fun dealing with
this project. Also, I hope I had done this first then figure why it doesn’t work the chatbot
wheel and other things. But instead I hope in the future to keep working on the robot
chatbot for my portfolio.

● Project Pictures / Video of Demonstration (YouTube links are preferred!)

https://youtu.be/TNWVGMJT3m4

You might also like