0% found this document useful (0 votes)
50 views4 pages

LCD 16X2 Programa 2

This document defines code for displaying custom characters and messages on a liquid crystal display (LCD). It includes code to initialize the LCD, define byte arrays for custom characters like a heart, smiley face, and person, and write those characters and messages to the LCD at different positions and times. The custom characters are created, stored, and can then be written out by their ID number. A potentiometer is used to control the delay time between animating a little man character between arms up and down positions on the bottom row of the LCD.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views4 pages

LCD 16X2 Programa 2

This document defines code for displaying custom characters and messages on a liquid crystal display (LCD). It includes code to initialize the LCD, define byte arrays for custom characters like a heart, smiley face, and person, and write those characters and messages to the LCD at different positions and times. The custom characters are created, stored, and can then be written out by their ID number. A potentiometer is used to control the delay time between animating a little man character between arms up and down positions on the bottom row of the LCD.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

// include the library code:

#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin

// with the arduino pin number it is connected to

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

// make some custom characters:

byte heart[8] = {

0b00000,

0b01010,

0b11111,

0b11111,

0b11111,

0b01110,

0b00100,

0b00000

};

byte smiley[8] = {

0b00000,

0b00000,

0b01010,

0b00000,

0b00000,

0b10001,

0b01110,

0b00000
};

byte frownie[8] = {

0b00000,

0b00000,

0b01010,

0b00000,

0b00000,

0b00000,

0b01110,

0b10001

};

byte armsDown[8] = {

0b00100,

0b01010,

0b00100,

0b00100,

0b01110,

0b10101,

0b00100,

0b01010

};

byte armsUp[8] = {

0b00100,

0b01010,

0b00100,

0b10101,
0b01110,

0b00100,

0b00100,

0b01010

};

void setup() {

// initialize LCD and set up the number of columns and rows:

lcd.begin(16, 2);

// create a new character

lcd.createChar(0, heart);

// create a new character

lcd.createChar(1, smiley);

// create a new character

lcd.createChar(2, frownie);

// create a new character

lcd.createChar(3, armsDown);

// create a new character

lcd.createChar(4, armsUp);

// set the cursor to the top left

lcd.setCursor(0, 0);

// Print a message to the lcd.

lcd.print("I ");

lcd.write(byte(0)); // when calling lcd.write() '0' must be cast as a byte

lcd.print("ELECTRONICA");

lcd.write((byte)1);
}

void loop() {

// read the potentiometer on A0:

int sensorReading = analogRead(A0);

// map the result to 200 - 1000:

int delayTime = map(sensorReading, 0, 1023, 200, 1000);

// set the cursor to the bottom row, 5th position:

lcd.setCursor(4, 1);

// draw the little man, arms down:

lcd.write(3);

delay(delayTime);

lcd.setCursor(4, 1);

// draw him arms up:

lcd.write(4);

delay(delayTime);

You might also like