0% found this document useful (0 votes)
2 views

8.11

The document contains Arduino code for controlling an LCD display using the LiquidCrystal library. It demonstrates how to initialize the LCD, print messages, and create custom characters. The code includes examples for both standard and I2C LCD connections.

Uploaded by

Suad Rodic
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)
2 views

8.11

The document contains Arduino code for controlling an LCD display using the LiquidCrystal library. It demonstrates how to initialize the LCD, print messages, and create custom characters. The code includes examples for both standard and I2C LCD connections.

Uploaded by

Suad Rodic
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/ 11

Helo 32

#include <LiquidCrystal.h>

// Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()

// set up the LCD's number of columns and rows:

lcd.begin(16, 2);

// Clears the LCD screen

lcd.clear();

void loop()

// Print a message to the LCD.


lcd.print(" Hello world!");

// set the cursor to column 0, line 1

// (note: line 1 is the second row, since counting begins with 0):

lcd.setCursor(0, 1);

// Print a message to the LCD.

lcd.print(" LCD Tutorial");

KARAKTERI

// include the library code:


#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins


LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// make some custom characters:


byte Heart[8] = {
0b00000,
0b01010,
0b11111,
0b11111,
0b01110,
0b00100,
0b00000,
0b00000
};

byte Bell[8] = {
0b00100,
0b01110,
0b01110,
0b01110,
0b11111,
0b00000,
0b00100,
0b00000
};

byte Alien[8] = {
0b11111,
0b10101,
0b11111,
0b11111,
0b01110,
0b01010,
0b11011,
0b00000
};

byte Check[8] = {
0b00000,
0b00001,
0b00011,
0b10110,
0b11100,
0b01000,
0b00000,
0b00000
};

byte Speaker[8] = {
0b00001,
0b00011,
0b01111,
0b01111,
0b01111,
0b00011,
0b00001,
0b00000
};

byte Sound[8] = {
0b00001,
0b00011,
0b00101,
0b01001,
0b01001,
0b01011,
0b11011,
0b11000
};

byte Skull[8] = {
0b00000,
0b01110,
0b10101,
0b11011,
0b01110,
0b01110,
0b00000,
0b00000
};

byte Lock[8] = {
0b01110,
0b10001,
0b10001,
0b11111,
0b11011,
0b11011,
0b11111,
0b00000
};

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, Bell);
// create a new character
lcd.createChar(2, Alien);
// create a new character
lcd.createChar(3, Check);
// create a new character
lcd.createChar(4, Speaker);
// create a new character
lcd.createChar(5, Sound);
// create a new character
lcd.createChar(6, Skull);
// create a new character
lcd.createChar(7, Lock);

// Clears the LCD screen


lcd.clear();

// Print a message to the lcd.


lcd.print("Custom Character");
}

// Print All the custom characters


void loop()
{
lcd.setCursor(0, 1);
lcd.write(byte(0));

lcd.setCursor(2, 1);
lcd.write(byte(1));

lcd.setCursor(4, 1);
lcd.write(byte(2));

lcd.setCursor(6, 1);
lcd.write(byte(3));

lcd.setCursor(8, 1);
lcd.write(byte(4));
lcd.setCursor(10, 1);
lcd.write(byte(5));

lcd.setCursor(12, 1);
lcd.write(byte(6));

lcd.setCursor(14, 1);
lcd.write(byte(7));
}
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column and 2


rows

byte customChar[8] = {
0b00000,
0b01010,
0b11111,
0b11111,
0b01110,
0b00100,
0b00000,
0b00000
};

void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight();

lcd.createChar(0, customChar); // create a new custom character

lcd.setCursor(2, 0); // move cursor to (2, 0)


lcd.write((byte)0); // print the custom char at (2, 0)
} srce

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C address 0x27, 16 column and 2
rows

byte customChar0[8] = {
0b00000,
0b01010,
0b11111,
0b11111,
0b01110,
0b00100,
0b00000,
0b00000
};

byte customChar1[8] = {
0b00100,
0b01110,
0b11111,
0b00100,
0b00100,
0b00100,
0b00100,
0b00100
};

byte customChar2[8] = {
0b00100,
0b00100,
0b00100,
0b00100,
0b00100,
0b11111,
0b01110,
0b00100
};

void setup()
{
lcd.init(); // initialize the lcd
lcd.backlight();

lcd.createChar(0, customChar0); // create a new custom character


(index 0)
lcd.createChar(1, customChar1); // create a new custom character
(index 1)
lcd.createChar(2, customChar2); // create a new custom character
(index 2)

lcd.setCursor(2, 0); // move cursor to (2, 0)


lcd.write((byte)0); // print the custom char 0 at (2, 0)

lcd.setCursor(4, 0); // move cursor to (4, 0)


lcd.write((byte)1); // print the custom char 1 at (4, 0)

lcd.setCursor(6, 0); // move cursor to (6, 0)


lcd.write((byte)2); // print the custom char 2 at (6, 0)
}

You might also like