More Related Content
PDF
Тененёв Анатолий, Boost.Asio в алгоритмической торговле PPTX
PPT
DOCX
DOC
TXT
DOC
PDF
Gaztea Tech 2015: 4. GT Drawbot Control What's hot
PDF
JavaScript Virus Code Example PDF
PDF
PPTX
Алексей Кутумов, C++ без исключений, часть 3 ODP
ODP
PDF
PDF
Фатальный недостаток Node.js PDF
PPTX
Como crear una matriz de 3x3 con c++ con menu PDF
PDF
I will be callback/JS同步與非同步 DOCX
PDF
PDF
PDF
openFrameworks基礎 動きを生みだす、アニメーション入門 - 芸大グラフィックスプログラミング演習B PDF
Week 7 unit3 (chapter 10-11) TXT
PDF
More from san jaramillo
PDF
PDF
a4-plantilla-isometrica.pdf PDF
Papel Cuadriculado -- Papel Rayado Isométrico de 0.5 cm.pdf PDF
EEF_Metacognition_and_self-regulated_learning.pdf PDF
dibujo-vistas-der-01 (1).pdf PPT
PDF
dibujo-vistas-der-01 (1).pdf PDF
maquinas-de-corte-guia-01.pdf PDF
PDF
Prueba tus conocimientos en microbitt!!! - Quizizz.pdf PDF
PDF
PDF
Herramientas,Maquinas e Instrumentos_ Sus Funciones y Su Mantenimiento _ Seba... DOCX
DOCX
DOCX
PDF
Papel Cuadriculado -- Papel Rayado Isométrico de 0.5 cm.pdf PDF
Dialnet-HacerVisibleElPensamiento-5263972.pdf PDF
PDF
Caculadora pacho (1)
- 1.
Caculadorapacho,
http://pocarduino.tumblr.com/
http://pocarduino.tumblr.com/post/84984103917/imagen-prototipo-de-simulación-del-arduino-en
#include <LiquidCrystal.h>
#include <Keypad.h>
LiquidCrystallcd(5,4, 3, 2, 1, 0);
const byte ROWS= 4;
const byte COLS = 4;
char keys [ROWS] [COLS] = {
{‘1’, '4’, '7’, 'X’},
{'2’, '5’, '8’, '0’},
{'3’, '6’, '9’, ’=’},
{’+’, ’-’, ’*’, ’/’}
};
byte rowPins[ROWS]= {13 ,12 ,11 ,10};
byte colPins[COLS]= {9, 8, 7, 6};
Keypad myKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
boolean numero1existe = false;
boolean next = false;
boolean final = false;
boolean operexiste =false;
String num1, num2;
int resp;
char op;
void setup(){
lcd.begin(16,2);
lcd.setCursor(2,0);
lcd.print(“CASIO 2.0v”);
delay(4000);
lcd.clear();
}
void loop(){
- 2.
char key =myKeypad.getKey();
if (key != NO_KEY && (key=='1’||key=='2’||key=='3’||key=='4’||key=='5’||key=='6’||key=='7’||
key=='8’||key=='9’||key=='0’)){
if (numero1existe != true){
num1 = num1 + key;
int numLength = num1.length();
lcd.setCursor(15 - numLength, 0);
lcd.print(num1);
}
else {
num2 = num2 + key;
int numLength = num2.length();
lcd.setCursor(15 - numLength, 1);
lcd.print(num2);
final = true;
}
}
else if (numero1existe == false && key != NO_KEY && (key == ’/’ || key == ’*’ || key == ’-’ || key == ’+’)){
if (numero1existe == false){
numero1existe = true;
op = key;
lcd.setCursor(15,0);
lcd.print(op);
}
}
else if (final == true && key != NO_KEY && key == ’=’){
if (op == ’+’){
resp = num1.toInt() + num2.toInt();
lcd.clear();
num1 = String(resp);
int numLength = num1.length();
lcd.setCursor(15 - numLength, 0);
lcd.print(num1);
resp = 0;
operexiste = true;
final = false;
- 3.
num2 = “”;
op= ’ ’;
}
else if (op == ’-’){
resp = num1.toInt() - num2.toInt();
lcd.clear();
num1 = String(resp);
int numLength = num1.length();
lcd.setCursor(15 - numLength, 0);
lcd.print(num1);
resp = 0;
operexiste = true;
final = false;
num2 = “”;
op = ’ ’;
}
else if (op == ’*’){
resp = num1.toInt() * num2.toInt();
lcd.clear();
num1 = String(resp);
int numLength = num1.length();
lcd.setCursor(15 - numLength, 0);
lcd.print(num1);
resp = 0;
operexiste = true;
final = false;
num2 = “”;
op = ’ ’;
}
else if (op == ’/’){
if(num2.toInt() == 0){
lcd.clear();
lcd.print(“Error”);
delay(1000);
lcd.clear();
operexiste = false;
numero1existe = false;
final = false;
num1 = “”;
num2 = “”;
- 4.
resp = 0;
op= ’ ’;
}
else{
resp = num1.toInt() / num2.toInt();
lcd.clear();
num1 = String(resp);
int numLength = num1.length();
lcd.setCursor(15 - numLength, 0);
lcd.print(num1);
resp = 0;
operexiste = true;
final = false;
num2 = “”;
op = ’ ’;
}
}
} else if (key != NO_KEY && (key == ’/’ || key == ’*’ || key == ’-’ || key == ’+’) && operexiste == true){
lcd.setCursor(15,0);
op=key;
lcd.print(op);
numero1existe = true;
}
else if (key != NO_KEY && key == 'X’){
lcd.clear();
operexiste = false;
numero1existe = false;
final = false;
num1 = “”;
num2 = “”;
resp = 0;
op = ’ ’;
}
}
- 5.