Вы находитесь на странице: 1из 11

PRACTICA 16.

DOS LINEAS DE MENSAJE CON DOS MENSAJES

/*
LiquidCrystal Library - Hello World
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.
This sketch prints "Hello World!" to the LCD
and shows the time.
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* 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 added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal
*/
// include the library code:
#include <LiquidCrystal.h>
// inicializa la librera con el nmero de pins de la interfase
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// Inicializa La LCD con el nmero de columnas y filas:
lcd.begin(16, 2);
// IMPRIME MENSAJE EN LA LCD.
}
void loop() {
lcd.setCursor(0, 0); //PRIMERA FILA
lcd.print("BIENVENIDOS AL ");
// (Nota: Lnea 1 es la segunda fila, la cuenta empieza desde 0):
lcd.setCursor(0, 1); //SEGUNDA FILA
lcd.print("CURSO DE ARDUINO");
delay(2000);
lcd.clear(); //Limpia la LCD
lcd.setCursor(0, 0); //PRIMERA FILA
lcd.print("NIVEL 1.0 PNF ");
lcd.setCursor(0, 1); //SEGUNDA FILA
lcd.print("INSTRUM. Y CONT.");
delay(2000);
lcd.clear(); //Limpia la LCD
}
PRCTICA 17. BLINK Y DISPLAY ON OFF
// include the library code:
#include <LiquidCrystal.h>
// inicializa la librera con el nmero de pins de la interfase
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {

// Inicializa La LCD con el nmero de columnas y filas:


lcd.begin(16, 2);
// Print a message to the LCD.
}
//lcd.setCursor(x, y);
void loop() {
lcd.setCursor(0, 0); //PRIMERA FILA
lcd.print("BIENVENIDOS AL ");
lcd.setCursor(0, 1); //SEGUNDA FILA
lcd.print("CURSO DE ARDUINO");
delay(2000);
lcd.noBlink(); //Observe el efecto del Blink off
delay(3000);
lcd.blink(); //Observe el efecto del Blink on
delay(3000);
lcd.noBlink();
// Turn off the display:
lcd.noDisplay(); //Observe el efecto del Display off
delay(1000);
// Turn on the display:
lcd.display(); //Observe el efecto del Display on
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("NIVEL 1.0 PNF ");
lcd.setCursor(0, 1);
lcd.print("INSTRUM. Y CONT.");
delay(2000);
lcd.noBlink();
delay(3000);
lcd.blink();
delay(3000);
lcd.noDisplay();
delay(1000);
lcd.display();
delay(1000);
lcd.clear();
}

PRCTICA 18. MENSAJES Y VARIABLES ENTERAS SALTEADAS EN LA MISMA LINEA


// include the library code:
#include <LiquidCrystal.h>
int VAR1=04;
int VAR2=35;
int VAR3=23;
int VAR4=98;
int VAR5=54;
int VAR6=10;
int VAR7=49;
int VAR8=72;
// inicializa la librera con el nmero de pins de la interfase
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// Inicializa La LCD con el nmero de columnas y filas:
lcd.begin(16, 2);
// Print a message to the LCD.
}
//lcd.setCursor(x, y);
void loop() {
lcd.setCursor(0, 0);
lcd.print("VAR1=");
lcd.setCursor(5, 0);
lcd.print(VAR1);
lcd.setCursor(8, 0);
lcd.print("VAR2=");
lcd.setCursor(13, 0);
lcd.print(VAR2);
lcd.setCursor(0, 1);
lcd.print("VAR3=");
lcd.setCursor(5, 1);
lcd.print(VAR3);
lcd.setCursor(8, 1);
lcd.print("VAR4=");
lcd.setCursor(13, 1);
lcd.print(VAR4);
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("VAR5=");
lcd.setCursor(5, 0);

lcd.print(VAR5);
lcd.setCursor(8, 0);
lcd.print("VAR6=");
lcd.setCursor(13, 0);
lcd.print(VAR6);
lcd.setCursor(0, 1);
lcd.print("VAR7=");
lcd.setCursor(5, 1);
lcd.print(VAR7);
lcd.setCursor(8, 1);
lcd.print("VAR8=");
lcd.setCursor(13, 1);
lcd.print(VAR8);
delay(2000);
lcd.clear();
}
PRCTICA 19. ESCRIBIENDO DESDE LA COMPUTADORA EN LA MISMA LNEA
// include the library code:
#include <LiquidCrystal.h>
int tope=0;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup(){
// Inicializa La LCD con el nmero de columnas y filas:
lcd.begin(16, 2);
// initialize the serial communications:
Serial.begin(9600);
}
void loop()
{
lcd.blink();
// delay(3000);
// when characters arrive over the serial port...
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
//lcd.clear();
// read all the available characters
while (Serial.available() > 0) {

// display each character to the LCD


lcd.write(Serial.read());
if (tope>=15){ //limita a 16 caracteres de la primera fila
lcd.setCursor(0, 0);
tope=0;
}
else{tope++;}
}
}
}

PRCTICA 20. CON BLINK Y/O CURSOR ESCRIBIENDO DESDE LA COMPUTADORA


// Escribe en las dos lneas de la LCD (entre 0 y 15 para primera lnea y 16 y 31 para la segunda
// lnea)
// Include the library code:
#include <LiquidCrystal.h>
int tope=0;
int linea=0;
// inicializa la librera con el nmero de pins de la interfase
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup(){
// Inicializa La LCD con el nmero de columnas y filas:
lcd.begin(16, 2);
// initialize the serial communications:
Serial.begin(9600);
lcd.setCursor(0, 0);
}
void loop()
{
//lcd.blink(); //Habilita blink de la LCD
lcd.cursor(); //Habilita el cursor de la LCD
// when characters arrive over the serial port...
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
//lcd.clear();
// read all the available characters
while (Serial.available() > 0) {

// display each character to the LCD


lcd.write(Serial.read());
if (tope>=15){
tope=0;
if (linea==0){
lcd.setCursor(0, 1);
linea=1;
}
else {linea=0;
lcd.setCursor(0, 0);
}
}
else{tope++;}
}
}
}
PRCTICA 21. MEDIDA DE ENTERO Y FLOTANTE CON RELLENO DE CEROS Y DELIMITACIN DE
DECIMALES

// include the library code:


#include <LiquidCrystal.h>
int sensorPin = A0;
int VALORSENSOR = 0;
float voltaje=0;
// inicializa la librera con el nmero de pins de la interfase
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// Inicializa La LCD con el nmero de columnas y filas:
lcd.begin(16, 2);
// Print a message to the LCD.
}
//lcd.setCursor(x, y);
void loop() {
VALORSENSOR = analogRead(sensorPin);
voltaje=(VALORSENSOR*0.004883);
//PRIMERA LNEA
lcd.setCursor(0, 0);
lcd.print("VAR1=");
//CON ESTOS IF SELECCIONAMOS EL RELLENO A LA IZQUIERDA CON CEROS
//EN LA PANTALLA LCD
if (VALORSENSOR<=99)
{
lcd.setCursor(5,0);
lcd.print("00");
lcd.setCursor(7,0);
lcd.print(VALORSENSOR);
}
if (VALORSENSOR>=100&VALORSENSOR<=999){
lcd.setCursor(5, 0);
lcd.print("0");
lcd.setCursor(6,0);
lcd.print(VALORSENSOR);
}
if (VALORSENSOR>=1000){
lcd.setCursor(5, 0);
lcd.print(VALORSENSOR);
}
//SEGUNDA LNEA
lcd.setCursor(0, 1);
lcd.print("VOLTAJE=");

lcd.setCursor(8, 1);
lcd.print(voltaje,3); //DELIMITO NMERO DE DECIMALES A 3 CON NMEROS FLOTANTES
delay(100);//OPCIONAL
}
PRCTICA 22. PIZARRA ELECTRNICA

// include the library code:


#include <LiquidCrystal.h>
int LOCAL=0;
int VISITA=0;
int PLOCAL = 8; // PIN del pulsador
int PVISITA=7;
int VALORL = 0; // Valor del pulsador
int VALORV=0;
// inicializa la librera con el nmero de pins de la interfase
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
pinMode(PLOCAL, INPUT); // Inicializa el pin 8 como entrada digital
pinMode(PVISITA, INPUT); // Inicializa el pin 7 como entrada digital

// Inicializa La LCD con el nmero de columnas y filas:


lcd.begin(16, 2);
// Print a message to the LCD.
lcd.setCursor(0, 0);
lcd.print("MARCADOR PIZARRA");
lcd.setCursor(0, 1);
lcd.print("UPTOS CR. IYC ");
delay(3000);
lcd.clear();
MOSTRAR();
}
void MOSTRAR(){
lcd.setCursor(0, 0);
lcd.print("PUNTOS LOCAL =");
//CON ESTOS IF SELECCIONAMOS EL RELLENO A LA IZQUIERDA CON CEROS
//EN LA PANTALLA LCD
if (LOCAL<=9)
{
lcd.setCursor(14,0);
lcd.print("0");
lcd.setCursor(15,0);
lcd.print(LOCAL);
}
else{
lcd.setCursor(14,0);
lcd.print(LOCAL);
}
//SEGUNDA LNEA
//CON ESTOS IF SELECCIONAMOS EL RELLENO A LA IZQUIERDA CON CEROS
//EN LA PANTALLA LCD
lcd.setCursor(0, 1);
lcd.print("PUNTOS VISITA=");
if (VISITA<=9)
{
lcd.setCursor(14,1);
lcd.print("0");
lcd.setCursor(15,1);
lcd.print(VISITA);
}
else{
lcd.setCursor(14,1);

lcd.print(VISITA);
}
}
//lcd.setCursor(x, y);
void loop() {
VALORL = digitalRead(PLOCAL); // lee el valor de la entrada digital pin 7
if (VALORL==0){
while (VALORL==0){
VALORL = digitalRead(PLOCAL); // lee el valor de la entrada digital pin 7
delay(20);}
if (LOCAL>=99){
LOCAL=0;
MOSTRAR();
}
else{
LOCAL++;
MOSTRAR();
}
}
else {
VALORV = digitalRead(PVISITA); // lee el valor de la entrada digital pin 8
if (VALORV==0){
while (VALORV==0){
VALORV = digitalRead(PVISITA); // lee el valor de la entrada digital pin 8
delay(20);}
if (VISITA>=99){
VISITA=0;
MOSTRAR();
}
else{
VISITA++;
MOSTRAR();
}
}
}
}

Вам также может понравиться