apuntes_Arduino/lcd/contador_loops/contador_loops.ino
2022-04-04 17:41:38 -04:00

84 lines
2.0 KiB
C++
Executable File

/*
LiquidCrystal Library - Contador de Loops
Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 9
* LCD D5 pin to digital pin 8
* LCD D6 pin to digital pin 7
* LCD D7 pin to digital pin 6
* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example 3 Feb 2018
by FuzanToko
*/
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 9, 8, 7, 6);
int var;
int var2;
int var3;
int contl;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
var = 0;
var2 = 0;
var3 = 0;
contl = 0;
}
void loop() {
lcd.setCursor(0, 0);
lcd.print("Contador x10: "+ (String)var);
lcd.setCursor(0, 1);
var2 += 1;
var3 += 1;
lcd.print("==== "+(String)var2+" ====");
if (var3 == 10) {
var3 = 0;
var += 1;
lcd.setCursor(0, 0);
lcd.print("Contador x10: "+ (String)var);
}
delay(100);
if (var > 99) {
contl += 1;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Se han contado :");
lcd.setCursor(0, 1);
lcd.print("* "+(String)contl+"000 loops *");
delay(5000);
lcd.clear();
var = 0;
var2 = 0;
if (contl == 10) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("...ya van 10000 ");
lcd.setCursor(0, 1);
lcd.print("fue suficiente!!");
delay(6000);
lcd.clear();
setup();
}
}
}