Informe P4 Word.docx

  • Uploaded by: Ivan C. Diaz
  • 0
  • 0
  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Informe P4 Word.docx as PDF for free.

More details

  • Words: 2,495
  • Pages: 10
UNIVERSIDAD MAYOR DE SAN ANDRÉS FACULTAD DE TECNOLOGÍA CARRERA DE ELECTROMECÁNICA

ETM 380 – SISTEMAS MICROPROCESADOS T4 – TECLADO Y LCD

INTEGRANTES: DIAZ ALCOREZA IVAN CAYO CHOQUE QUISPE JOSEAN VILLCA QUISPE GROVER

Docente: Ing. Roberto Escalante Mendoza Fecha: 11/04/2019

TECLADO Y LCD 1. Programa que calcula la suma de dos números LCD1 LM016L

RESET

ANALOG IN

A0 A1 A2 A3 A4 A5

PC0/ADC0 PC1/ADC1 PC2/ADC2 PC3/ADC3 PC4/ADC4/SDA PC5/ADC5/SCL

1121 ATMEGA328P-PU

VCC GND

www.TheEngineeringProjects.com

10k

7 8 9 10 11 12 13 14

D0 D1 D2 D3 D4 D5 D6 D7

RS RW E

ON

Reset BTN

R1

4 5 6

1 2 3

VSS VDD VEE

ARD1

AREF PB5/SCK PB4/MISO ~PB3/MOSI/OC2A ~PB2/SS/OC1B ~ PB1/OC1A PB0/ICP1/CLKO PD7/AIN1 ~ PD6/AIN0 ~ PD5/T1 PD4/T0/XCK ~ PD3/INT1 PD2/INT0 TX PD1/TXD RX PD0/RXD

13 12 11 10 9 8 7 6 5 4 3 2 1 0

1

2

3

ARDUINO UNO

A

1

2

3

B

4

5

6

C

7

8

9

0

#

D

CODIGO DE EJECUCION #include #include LiquidCrystal lcd(12,13,4,5,6,7); //RS,E,DB4,DB5,DB6,DB7 const byte ROWS = 4; const byte COLS = 3; char keys[ROWS][COLS]={ {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'}, }; byte rowPins[ROWS]={16,17,18,19}; byte colPins[COLS]={3,14,15}; Keypad keypad = Keypad(makeKeymap(keys),rowPins, colPins,ROWS,COLS); void setup() { lcd.begin(16,2); } void loop() { int n1, n2, sum; lcd.clear();

lcd.blink(); lcd.print("Numero 1 "); lcd.setCursor(0,1); lcd.print(">"); n1 = leeNumero(); lcd.clear(); lcd.print("Numero 2 "); lcd.setCursor(0,1); lcd.print(">"); n2 = leeNumero(); delay(500); sum = n1 + n2; lcd.clear(); lcd.print("Suma: "); lcd.print(sum); lcd.noBlink(); while(1); } byte leeNumero() { char aux; byte i=0, k, num=0, p, teclas[3]; //lee los dígitos

do{ aux=NO_KEY; while(aux==NO_KEY){ aux=keypad.getKey(); } if(aux != '#'){ teclas[i]=aux; lcd.print(aux); i++; } }while(aux != '#'&& i < 2); //Convierte los digitos a números for(k=0; k < i; ++k){ teclas[k] = teclas[k]&0x0f; } //Obtiene el valor numérico p = i-1; for(k=0; k < i; ++k){ num = num + teclas[k]*pow(10,p); p=p-1; } delay(200); return num;

2. Programa que calcula la suma de los primeros n números naturalesLCD1 LM016L

RESET

ANALOG IN

A0 A1 A2 A3 A4 A5

PC0/ADC0 PC1/ADC1 PC2/ADC2 PC3/ADC3 PC4/ADC4/SDA PC5/ADC5/SCL

1121 ATMEGA328P-PU

VCC GND

www.TheEngineeringProjects.com

10k

7 8 9 10 11 12 13 14

D0 D1 D2 D3 D4 D5 D6 D7

RS RW E

ON

Reset BTN

R1

4 5 6

1 2 3

VSS VDD VEE

ARD1

AREF PB5/SCK PB4/MISO ~PB3/MOSI/OC2A ~PB2/SS/OC1B ~ PB1/OC1A PB0/ICP1/CLKO PD7/AIN1

~ PD6/AIN0 ~ PD5/T1 PD4/T0/XCK ~ PD3/INT1 PD2/INT0 TX PD1/TXD RX PD0/RXD

13 12 11 10 9 8 7 6 5 4 3 2 1 0

1

2

3

ARDUINO UNO

A

1

2

3

B

4

5

6

C

7

8

9

0

#

D

CODIGO DE EJECUCIÓN #include #include LiquidCrystal lcd(12,13,4,5,6,7); //RS,E,DB4,DB5,DB6,DB7 const byte ROWS = 4; const byte COLS = 3; char keys[ROWS][COLS]={ {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'}, }; byte rowPins[ROWS]={16,17,18,19}; byte colPins[COLS]={3,14,15}; Keypad keypad = Keypad(makeKeymap(keys),rowPi ns,colPins,ROWS,COLS); void setup() { lcd.begin(16,2); }

void loop() { int n, s=0, i=1; lcd.clear(); lcd.blink(); lcd.print("Numero: "); n = leeNumero(); do{ s=s+i; i++; }while(i<=n); delay(200); lcd.setCursor(0,1); lcd.print("Suma: "); lcd.print(s); lcd.noBlink(); while(1); } byte leeNumero() { char aux; byte i=0, k, num=0, p, teclas[3]; //lee los dígitos do{

aux=NO_KEY; while(aux==NO_KEY){ aux=keypad.getKey(); } if(aux != '#'){ teclas[i]=aux; lcd.print(aux); i++; } }while(aux != '#'&& i < 2); //Convierte los digitos a números for(k=0; k < i; ++k){ teclas[k] = teclas[k]&0x0f; } //Obtiene el valor numérico p = i-1; for(k=0; k < i; ++k){ num = num + teclas[k]*pow(10,p); p=p-1; } delay(200); return num;

3. Implementar un programa que calcule el factorial deLCD1 un número. LM016L

RESET

ANALOG IN

A0 A1 A2 A3 A4 A5

PC0/ADC0 PC1/ADC1 PC2/ADC2 PC3/ADC3 PC4/ADC4/SDA PC5/ADC5/SCL

1121 ATMEGA328P-PU

VCC GND

www.TheEngineeringProjects.com

10k

7 8 9 10 11 12 13 14

D0 D1 D2 D3 D4 D5 D6 D7

RS RW E

ON

Reset BTN

R1

4 5 6

1 2 3

VSS VDD VEE

ARD1

AREF PB5/SCK PB4/MISO ~PB3/MOSI/OC2A ~PB2/SS/OC1B ~ PB1/OC1A PB0/ICP1/CLKO PD7/AIN1

~ PD6/AIN0 ~ PD5/T1 PD4/T0/XCK ~ PD3/INT1 PD2/INT0 TX PD1/TXD RX PD0/RXD

13 12 11 10 9 8 7 6 5 4 3 2 1 0

1

2

3

ARDUINO UNO

A

1

2

3

B

4

5

6

C

7

8

9

0

#

D

CODIGO DE EJECUCIÓN #include #include LiquidCrystal lcd(12,13,4,5,6,7); //RS,E,DB4,DB5,DB6,DB7 const byte ROWS = 4; const byte COLS = 3; char keys[ROWS][COLS]={ {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'}, }; byte rowPins[ROWS]={16,17,18,19}; byte colPins[COLS]={3,14,15}; Keypad keypad = Keypad(makeKeymap(keys),rowPi ns,colPins,ROWS,COLS); void setup() { lcd.begin(16,2); } void loop() { long n, s=1, i=1;

lcd.clear(); lcd.blink(); lcd.print("Numero: "); n = leeNumero(); do{ s=s*i; i++; }while(i<=n); delay(200); lcd.setCursor(0,1); lcd.print("FACT: "); lcd.print(s); lcd.noBlink(); while(1); } byte leeNumero() { char aux; byte i=0, k, num=0, p, teclas[3]; //lee los dígitos do{ aux=NO_KEY; while(aux==NO_KEY){

aux=keypad.getKey(); } if(aux != '#'){ teclas[i]=aux; lcd.print(aux); i++; } }while(aux != '#'&& i < 2); //Convierte los digitos a números for(k=0; k < i; ++k){ teclas[k] = teclas[k]&0x0f; } //Obtiene el valor numérico p = i-1; for(k=0; k < i; ++k){ num = num + teclas[k]*pow(10,p); p=p-1; } delay(200); return num;

4. Implementar un programa que calcule la suma de los primeros n números pares. LCD1 LM016L

RESET

ANALOG IN

A0 A1 A2 A3 A4 A5

PC0/ADC0 PC1/ADC1 PC2/ADC2 PC3/ADC3 PC4/ADC4/SDA PC5/ADC5/SCL

1121 ATMEGA328P-PU

VCC GND

www.TheEngineeringProjects.com

10k

7 8 9 10 11 12 13 14

D0 D1 D2 D3 D4 D5 D6 D7

RS RW E

ON

Reset BTN

R1

4 5 6

1 2 3

VSS VDD VEE

ARD1

AREF PB5/SCK PB4/MISO ~PB3/MOSI/OC2A ~PB2/SS/OC1B ~ PB1/OC1A PB0/ICP1/CLKO PD7/AIN1

~ PD6/AIN0 ~ PD5/T1 PD4/T0/XCK ~ PD3/INT1 PD2/INT0 TX PD1/TXD RX PD0/RXD

13 12 11 10 9 8 7 6 5 4 3 2 1 0

1

2

3

ARDUINO UNO

A

1

2

3

B

4

5

6

C

7

8

9

0

#

D

CODIGO DE EJECUCIÓN #include #include LiquidCrystal lcd(12,13,4,5,6,7); //RS,E,DB4,DB5,DB6,DB7 const byte ROWS = 4; const byte COLS = 3; char keys[ROWS][COLS]={ {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'}, }; byte rowPins[ROWS]={16,17,18,19}; byte colPins[COLS]={3,14,15}; Keypad keypad = Keypad(makeKeymap(keys),rowPi ns,colPins,ROWS,COLS); void setup() { lcd.begin(16,2); } void loop() { int n, s=0, i=1,a;

lcd.clear(); lcd.blink(); lcd.print("Numero: "); n = leeNumero(); do{ a=2*i; s=s+a; i++; }while(i<=n); delay(200); lcd.setCursor(0,1); lcd.print("Suma: "); lcd.print(s); lcd.noBlink(); while(1); } byte leeNumero() { char aux; byte i=0, k, num=0, p, teclas[3]; //lee los dígitos do{ aux=NO_KEY;

while(aux==NO_KEY){ aux=keypad.getKey(); } if(aux != '#'){ teclas[i]=aux; lcd.print(aux); i++; } }while(aux != '#'&& i < 2); //Convierte los digitos a números for(k=0; k < i; ++k){ teclas[k] = teclas[k]&0x0f; } //Obtiene el valor numérico p = i-1; for(k=0; k < i; ++k){ num = num + teclas[k]*pow(10,p); p=p-1; } delay(200); return num;

5. Implementar un programa que calcule la suma de los primeros LCD1 n términos de la serie: LM016L

RESET

ANALOG IN

A0 A1 A2 A3 A4 A5

PC0/ADC0 PC1/ADC1 PC2/ADC2 PC3/ADC3 PC4/ADC4/SDA PC5/ADC5/SCL

1121 ATMEGA328P-PU

VCC GND

www.TheEngineeringProjects.com

10k

PD7/AIN1 ~ PD6/AIN0 ~ PD5/T1 PD4/T0/XCK ~ PD3/INT1 PD2/INT0 TX PD1/TXD RX PD0/RXD

13 12 11 10 9 8 7 6 5 4 3 2 1 0

1

2

3

A

1

2

3

B

4

5

6

C

7

8

9

0

#

D

double n, s=0, i=1,a;

7 8 9 10 11 12 13 14

AREF PB5/SCK PB4/MISO ~PB3/MOSI/OC2A ~PB2/SS/OC1B ~ PB1/OC1A PB0/ICP1/CLKO

ARDUINO UNO

#include #include LiquidCrystal lcd(12,13,4,5,6,7); //RS,E,DB4,DB5,DB6,DB7 const byte ROWS = 4; const byte COLS = 3; char keys[ROWS][COLS]={ {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'}, }; byte rowPins[ROWS]={16,17,18,19}; byte colPins[COLS]={3,14,15}; Keypad keypad = Keypad(makeKeymap(keys),rowPins, colPins,ROWS,COLS); void setup() { lcd.begin(16,2); } void loop() {

D0 D1 D2 D3 D4 D5 D6 D7

RS RW E

ON

Reset BTN

R1

4 5 6

1 2 3

VSS VDD VEE

ARD1

lcd.clear(); lcd.blink(); lcd.print("Numero: "); n = leeNumero(); do{ a=((2*i)-1)/(2*i); s=s+a; i++; }while(i<=n); delay(200); lcd.setCursor(0,1); lcd.print("Suma: "); lcd.print(s); lcd.noBlink(); while(1); } byte leeNumero() { char aux; byte i=0, k, num=0, p, teclas[3];

//lee los dígitos do{ aux=NO_KEY; while(aux==NO_KEY){ aux=keypad.getKey(); } if(aux != '#'){ teclas[i]=aux; lcd.print(aux); i++; } }while(aux != '#'&& i < 2); //Convierte los digitos a números for(k=0; k < i; ++k){ teclas[k] = teclas[k]&0x0f; } //Obtiene el valor numérico p = i-1; for(k=0; k < i; ++k){ num = num + teclas[k]*pow(10,p); p=p-1; } delay(200); return num;

LCD1 6. Implementar un programa que calcule el seno de un número x. LM016L

RESET

ANALOG IN

A0 A1 A2 A3 A4 A5

PC0/ADC0 PC1/ADC1 PC2/ADC2 PC3/ADC3 PC4/ADC4/SDA PC5/ADC5/SCL

1121 ATMEGA328P-PU

VCC GND

www.TheEngineeringProjects.com

10k

D0 D1 D2 D3 D4 D5 D6 D7 7 8 9 10 11 12 13 14

AREF PB5/SCK PB4/MISO ~PB3/MOSI/OC2A ~PB2/SS/OC1B ~ PB1/OC1A PB0/ICP1/CLKO PD7/AIN1

~ PD6/AIN0 ~ PD5/T1 PD4/T0/XCK ~ PD3/INT1 PD2/INT0 TX PD1/TXD RX PD0/RXD

13 12 11 10 9 8 7 6 5 4 3 2 1 0

1

2

3

ARDUINO UNO

A

1

2

3

B

4

5

6

C

7

8

9

0

#

D

CODIGO DE EJECUCIÓN #include #include LiquidCrystal lcd(12,13,4,5,6,7); //RS,E,DB4,DB5,DB6,DB7 const byte ROWS = 4; const byte COLS = 3; char keys[ROWS][COLS]={ {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'}, }; byte rowPins[ROWS]={16,17,18,19}; byte colPins[COLS]={3,14,15}; Keypad keypad = Keypad(makeKeymap(keys),rowPi ns,colPins,ROWS,COLS); void setup() { lcd.begin(16,2); }

RS RW E

ON

Reset BTN

R1

4 5 6

1 2 3

VSS VDD VEE

ARD1

void loop() { double n,s; lcd.clear(); lcd.blink(); lcd.print("Numero X: "); n = leeNumero(); delay(200); s=sin(n); lcd.setCursor(0,1); lcd.print("Seno: "); lcd.print(s,6); lcd.noBlink(); while(1); } byte leeNumero() { char aux; byte i=0, k, num=0, p, teclas[3]; //lee los dígitos do{ aux=NO_KEY; while(aux==NO_KEY){

aux=keypad.getKey(); } if(aux != '#'){ teclas[i]=aux; lcd.print(aux); i++; } }while(aux != '#'&& i < 2); //Convierte los digitos a números for(k=0; k < i; ++k){ teclas[k] = teclas[k]&0x0f; } //Obtiene el valor numérico p = i-1; for(k=0; k < i; ++k){ num = num + teclas[k]*pow(10,p); p=p-1; } delay(200); return num;

7. Elaborar un programa que calcule el promedio de tresLCD1 números introducidos desde el teclado. LM016L

RESET

ANALOG IN

A0 A1 A2 A3 A4 A5

PC0/ADC0 PC1/ADC1 PC2/ADC2 PC3/ADC3 PC4/ADC4/SDA PC5/ADC5/SCL

1121 ATMEGA328P-PU

VCC GND

www.TheEngineeringProjects.com

10k

7 8 9 10 11 12 13 14

D0 D1 D2 D3 D4 D5 D6 D7

RS RW E

ON

Reset BTN

R1

4 5 6

1 2 3

VSS VDD VEE

ARD1

AREF PB5/SCK PB4/MISO ~PB3/MOSI/OC2A ~PB2/SS/OC1B ~ PB1/OC1A PB0/ICP1/CLKO PD7/AIN1

~ PD6/AIN0 ~ PD5/T1 PD4/T0/XCK ~ PD3/INT1 PD2/INT0 TX PD1/TXD RX PD0/RXD

13 12 11 10 9 8 7 6 5 4 3 2 1 0

1

2

3

ARDUINO UNO

A

1

2

3

B

4

5

6

C

7

8

9

0

#

D

CODIGO DE EJECUCIÓN #include #include LiquidCrystal lcd(12,13,4,5,6,7); //RS,E,DB4,DB5,DB6,DB7 const byte ROWS = 4; const byte COLS = 3; char keys[ROWS][COLS]={ {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'}, }; byte rowPins[ROWS]={16,17,18,19}; byte colPins[COLS]={3,14,15}; Keypad keypad = Keypad(makeKeymap(keys),rowPins, colPins,ROWS,COLS); void setup() { lcd.begin(16,2); } void loop() { double a,b,c,s; lcd.clear(); lcd.blink(); lcd.print("Numero 1: "); lcd.setCursor(0,1);

a = leeNumero(); lcd.clear(); lcd.blink(); lcd.print("Numero 2: "); lcd.setCursor(0,1); b = leeNumero(); lcd.clear(); lcd.blink(); lcd.print("Numero 3: "); lcd.setCursor(0,1); c = leeNumero(); lcd.clear(); lcd.blink(); delay(200); lcd.setCursor(1,0); lcd.print("Promedio: "); lcd.setCursor(0,1); s=(a+b+c)/3; lcd.print(s,2); lcd.noBlink(); while(1); } byte leeNumero() { char aux; byte i=0, k, num=0, p, teclas[3];

//lee los dígitos do{ aux=NO_KEY; while(aux==NO_KEY){ aux=keypad.getKey(); } if(aux != '#'){ teclas[i]=aux; lcd.print(aux); i++; } }while(aux != '#'&& i < 2); //Convierte los digitos a números for(k=0; k < i; ++k){ teclas[k] = teclas[k]&0x0f; } //Obtiene el valor numérico p = i-1; for(k=0; k < i; ++k){ num = num + teclas[k]*pow(10,p); p=p-1; } delay(200); return num;

8. Elaborar un programa que implemente una caja registradora de un supermercado según la siguiente lógica: LCD1 LM016L

RESET

ANALOG IN

A0 A1 A2 A3 A4 A5

PC0/ADC0 PC1/ADC1 PC2/ADC2 PC3/ADC3 PC4/ADC4/SDA PC5/ADC5/SCL

1121 ATMEGA328P-PU

VCC GND

www.TheEngineeringProjects.com

10k

7 8 9 10 11 12 13 14

D0 D1 D2 D3 D4 D5 D6 D7

RS RW E

ON

Reset BTN

R1

4 5 6

1 2 3

VSS VDD VEE

ARD1

AREF PB5/SCK PB4/MISO ~PB3/MOSI/OC2A ~PB2/SS/OC1B ~ PB1/OC1A PB0/ICP1/CLKO PD7/AIN1

~ PD6/AIN0 ~ PD5/T1 PD4/T0/XCK ~ PD3/INT1 PD2/INT0 TX PD1/TXD RX PD0/RXD

13 12 11 10 9 8 7 6 5 4 3 2 1 0

1

2

3

ARDUINO UNO

A

1

2

3

B

4

5

6

C

7

8

9

0

#

D

CODIGO DE #include #include LiquidCrystal lcd(12,13,4,5,6,7); //RS,E,DB4,DB5,DB6,DB7 const byte ROWS = 4; const byte COLS = 3; char keys[ROWS][COLS]={ {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'}, }; byte rowPins[ROWS]={16,17,18,19}; byte colPins[COLS]={3,14,15}; Keypad keypad = Keypad(makeKeymap(keys),rowPins,colPi ns,ROWS,COLS); void setup() { lcd.begin(16,2); } void loop() { double a,b,c,d,total; lcd.clear(); lcd.blink(); lcd.print("1er Producto: "); lcd.setCursor(0,1); lcd.print("Bs: "); a = leeNumero(); lcd.clear();

EJECUCIÓN lcd.blink(); lcd.print("2do Producto: "); lcd.setCursor(0,1); lcd.print("Bs: "); b = leeNumero(); lcd.clear(); lcd.blink(); lcd.print("3er Producto: "); lcd.setCursor(0,1); lcd.print("Bs: "); c = leeNumero(); lcd.clear(); lcd.blink(); lcd.print("4to Producto: "); lcd.setCursor(0,1); lcd.print("Bs: "); d = leeNumero(); lcd.clear(); lcd.blink(); delay(200); total=a+b+c+d; lcd.setCursor(1,0); lcd.print ("Total: "); lcd.print(total); lcd.setCursor(0,1); lcd.print("Gracias por su compra"); lcd.noBlink(); while(1); }

byte leeNumero() { char aux; byte i=0, k, num=0, p, teclas[3]; //lee los dígitos do{ aux=NO_KEY; while(aux==NO_KEY){ aux=keypad.getKey(); } if(aux != '#'){ teclas[i]=aux; lcd.print(aux); i++; } }while(aux != '#'&& i < 2); //Convierte los digitos a números for(k=0; k < i; ++k){ teclas[k] = teclas[k]&0x0f; } //Obtiene el valor numérico p = i-1; for(k=0; k < i; ++k){ num = num + teclas[k]*pow(10,p); p=p-1; } delay(200); return num;

9. Implementar un programa que implemente un reloj digital: LCD1 LM016L

RESET

ANALOG IN

A0 A1 A2 A3 A4 A5

PC0/ADC0 PC1/ADC1 PC2/ADC2 PC3/ADC3 PC4/ADC4/SDA PC5/ADC5/SCL

1121 ATMEGA328P-PU

VCC GND

www.TheEngineeringProjects.com

10k

7 8 9 10 11 12 13 14

D0 D1 D2 D3 D4 D5 D6 D7

RS RW E

ON

Reset BTN

R1

4 5 6

1 2 3

VSS VDD VEE

ARD1

AREF PB5/SCK PB4/MISO ~PB3/MOSI/OC2A ~PB2/SS/OC1B ~ PB1/OC1A PB0/ICP1/CLKO PD7/AIN1

~ PD6/AIN0 ~ PD5/T1 PD4/T0/XCK ~ PD3/INT1 PD2/INT0 TX PD1/TXD RX PD0/RXD

13 12 11 10 9 8 7 6 5 4 3 2 1 0

1

2

3

ARDUINO UNO

A

1

2

3

B

4

5

6

C

7

8

9

0

#

D

CODIGO DE EJECUCIÓN #include <Time.h> #include <TimeLib.h> #include #include LiquidCrystal lcd(12,13,4,5,6,7); //RS,E,DB4,DB5,DB6,DB7 const byte ROWS = 4; const byte COLS = 3; char keys[ROWS][COLS]={ {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'}, }; byte rowPins[ROWS]={16,17,18,19}; byte colPins[COLS]={3,14,15}; Keypad keypad = Keypad(makeKeymap(keys),rowPins,colPi ns,ROWS,COLS); void setup() { lcd.begin(16,2); } void loop() { int ho, mi, se, di, me, an; time_t t; int s=0, n, i=1; lcd.clear(); lcd.print("Configurando"); borraFila(); lcd.print("Hora: "); ho = leeNumero(); borraFila(); lcd.print("Minuto: ");

mi = leeNumero(); borraFila(); lcd.print("Segundos: "); se = leeNumero(); borraFila(); lcd.print("Dia: "); di = leeNumero(); borraFila(); lcd.print("Mes: "); me = leeNumero(); borraFila(); lcd.print("Año: "); an = leeNumero(); an = an+2000; setTime(ho,mi,se,di,me,an); do{ t = now(); lcd.clear(); lcd.print(day()); lcd.print("/"); lcd.print(month()); lcd.print("/"); lcd.print(year()); lcd.setCursor(0,1); lcd.print(hour()); lcd.print(":"); lcd.print(minute()); lcd.print(":"); lcd.print(second()); delay(1000); }while(1); } byte leeNumero()

{ char aux; byte i=0, k, num=0, p, teclas[3]; //lee los dígitos do{ aux=NO_KEY; while(aux==NO_KEY){ aux=keypad.getKey(); } if(aux != '#'){ teclas[i]=aux; lcd.print(aux); i++; } }while(aux != '#'&& i < 2); //Convierte los digitos a números for(k=0; k < i; ++k){ teclas[k] = teclas[k]&0x0f; } //Obtiene el valor numérico p = i-1; for(k=0; k < i; ++k){ num = num + teclas[k]*pow(10,p); p=p-1; } delay(200); return num; } void borraFila() { lcd.setCursor(0,1); lcd.print(""); lcd.setCursor(0,1);

Related Documents

Informe P4 Word.docx
October 2019 18
P4
November 2019 34
P4
June 2020 29
P4
June 2020 23
P4
May 2020 19
P4
December 2019 39

More Documents from "R. Tamminga"

Informe P4 Word.docx
October 2019 18
Formato Limpio.docx
December 2019 9
April 2020 4
April 2020 5