Components and supplies
Arduino Nano R3
Alphanumeric LCD, 16 x 2
Apps and platforms
Arduino IDE
Project description
Code
Code example: lcd.createChar - creating composite clipart out of multiple custom characters
arduino
1#include <LiquidCrystal.h> 2 3const int rs = 2, 4 en = 3, 5 d4 = 6, 6 d5 = 7, 7 d6 = 8, 8 d7 = 9; 9 10LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 11 12byte S1[8] = { 13 0b00000, 14 0b00000, 15 0b00011, 16 0b00100, 17 0b01000, 18 0b01000, 19 0b10000, 20 0b10000 21}; 22 23byte S2[8] = { 24 0b00000, 25 0b11111, 26 0b00000, 27 0b00000, 28 0b00000, 29 0b11011, 30 0b11011, 31 0b11011 32}; 33 34byte S3[8] = { 35 0b00000, 36 0b00000, 37 0b11000, 38 0b00100, 39 0b00010, 40 0b00010, 41 0b00001, 42 0b00001 43}; 44 45 46byte S4[8] = { 47 0b10000, 48 0b10010, 49 0b01001, 50 0b01000, 51 0b00100, 52 0b00011, 53 0b00000 54}; 55 56 57byte S5[8] = { 58 0b00000, 59 0b00000, 60 0b00000, 61 0b11111, 62 0b00000, 63 0b00000, 64 0b11111 65}; 66 67 68byte S6[8] = { 690b00001, 700b01001, 710b10010, 720b00010, 730b00100, 740b11000, 750b00000 76}; 77 78void setup() { 79 lcd.begin(16, 2); 80 Serial.begin(9600); 81 lcd.begin(16, 2); 82 83 // create a new character 84 lcd.createChar(0,S1); 85 // create a new character 86 lcd.createChar(1,S2); 87 // create a new character 88 lcd.createChar(2,S3); 89 // create a new character 90 lcd.createChar(3,S4); 91 // create a new character 92 lcd.createChar(4,S5); 93 // create a new character 94 lcd.createChar(5,S6); 95 lcd.clear(); 96 delay(3000); 97} 98 99 100 101void loop() { 102 103// set the cursor to the top left 104 lcd.setCursor(0, 0); 105 lcd.write(byte(0)); 106 lcd.write((byte)1); 107 lcd.write((byte)2); 108 lcd.setCursor(0, 1); 109 lcd.write((byte)3); 110 lcd.write((byte)4); 111 lcd.write((byte)5); 112 113 }
Code example: lcd.blink, lcd.noblink, lcd.clear
arduino
1#include <LiquidCrystal.h> 2 3const int rs = 2, 4 en = 3, 5 d4 = 6, 6 d5 = 7, 7 d6 = 8, 8 d7 = 9; 9 10LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 11 12void setup() { 13 lcd.begin(16, 2); 14 Serial.begin(9600); 15} 16 17 18String Hello="Hello World!"; 19 20void loop() { 21 lcd.clear(); //d 22 delay(4000);// 23 lcd.blink(); 24 lcd.setCursor(0, 0); 25 delay(6000); //2000 26 27 for(int i=0;i<Hello.length();i++){ 28 lcd.print(Hello.charAt(i)); 29 delay(400); 30 } 31 delay(6000);//2000 32 lcd.noBlink(); 33 delay(3000); 34 lcd.clear(); 35}
Code example: lcd. autoscroll, lcd.noautoscroll
arduino
1#include <LiquidCrystal.h> 2 3const int rs = 2, 4 en = 3, 5 d4 = 6, 6 d5 = 7, 7 d6 = 8, 8 d7 = 9; 9 10LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 11 12void setup() { 13 lcd.begin(16, 2); 14 Serial.begin(9600); 15} 16 17String Mario="Mario's Ideas "; 18 19void loop() { 20 lcd.clear() ; //d 21 delay(3000);//d 22 23 for(int i=0;i<Mario.length();i++){ 24 lcd.print(Mario.charAt(i)); 25 delay(200); 26 } 27 lcd.setCursor(16, 1); 28 lcd.autoscroll(); 29 for(int i=0;i<Mario.length();i++){ 30 lcd.print(Mario.charAt(i)); 31 delay(400); 32 } 33 lcd.noAutoscroll(); 34 lcd.clear(); 35}
Code example: lcd.createChar - creating single custom character
arduino
1#include <LiquidCrystal.h> 2 3const int rs = 2, 4 en = 3, 5 d4 = 6, 6 d5 = 7, 7 d6 = 8, 8 d7 = 9; 9 10LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 11 12byte bot[8] = { 13 0b01110, 14 0b01110, 15 0b00100, 16 0b11111, 17 0b00100, 18 0b00100, 19 0b01010, 20 0b10001 21}; 22 23 24void setup() { 25 lcd.begin(16, 2); 26 Serial.begin(9600); 27 28 lcd.createChar(0,bot); 29 lcd.clear(); 30 delay(2000); 31 32 33} 34 35 36 37void loop() { 38 lcd.setCursor(0, 0); 39 lcd.write(byte(0)); 40 delay(6000); 41 for (int j=0;j<2;j++) 42 for (int i=0;i<16;i++){ 43 lcd.setCursor(i, j); 44 lcd.write(byte(0)); 45 delay(100); 46 } 47 48 }
Code example: lcd.lefttoRight, lcd.righttoLeft, lcd.home, lcd.display, lcd.nodisplay
arduino
1#include <LiquidCrystal.h> 2 3const int rs = 2, 4 en = 3, 5 d4 = 6, 6 d5 = 7, 7 d6 = 8, 8 d7 = 9; 9 10LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 11 12void setup() { 13 lcd.begin(16, 2); 14 Serial.begin(9600); 15} 16 17 18String Hello="Hello World!"; 19 20void loop() { 21 lcd.clear(); delay(4000); 22 lcd.setCursor(7, 0); 23 lcd.rightToLeft(); 24 lcd.print("TFEL-<"); 25 26 delay(4000); 27 28 lcd.setCursor(7, 1); 29 lcd.leftToRight(); 30 lcd.print("RIGHT->"); 31 32 delay(2000); 33 34 lcd.blink();delay(4000); 35 lcd.home();delay(4000); 36 37 lcd.noDisplay(); delay(4000); 38 lcd.display(); delay(4000); 39 lcd.clear(); delay(4000); 40 41}
Code example : lcd print, lcd.setCursor,
arduino
1#include <LiquidCrystal.h> 2 3const int rs = 2, 4 en = 3, 5 d4 = 6, 6 d5 = 7, 7 d6 = 8, 8 d7 = 9; 9 10LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 11 12void setup() { 13 lcd.begin(16, 2); 14 Serial.begin(9600); 15 lcd.setCursor(0, 0); 16 lcd.print("Hello world"); 17}
Code example: lcd. autoscroll, lcd.noautoscroll
arduino
1#include <LiquidCrystal.h> 2 3const int rs = 2, 4 en = 5 3, 6 d4 = 6, 7 d5 = 7, 8 d6 = 8, 9 d7 10 = 9; 11 12LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 13 14void setup() { 15 16 lcd.begin(16, 2); 17 Serial.begin(9600); 18} 19 20String Mario="Mario's 21 Ideas "; 22 23void loop() { 24 lcd.clear() ; //d 25 delay(3000);//d 26 27 28 for(int i=0;i<Mario.length();i++){ 29 lcd.print(Mario.charAt(i)); 30 31 delay(200); 32 } 33 lcd.setCursor(16, 1); 34 lcd.autoscroll(); 35 for(int 36 i=0;i<Mario.length();i++){ 37 lcd.print(Mario.charAt(i)); 38 delay(400); 39 40 } 41 lcd.noAutoscroll(); 42 lcd.clear(); 43}
Code example: lcd.blink, lcd.noblink, lcd.clear
arduino
1#include <LiquidCrystal.h> 2 3const int rs = 2, 4 en = 3, 5 d4 = 6, 6 d5 = 7, 7 d6 = 8, 8 d7 = 9; 9 10LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 11 12void setup() { 13 lcd.begin(16, 2); 14 Serial.begin(9600); 15} 16 17 18String Hello="Hello World!"; 19 20void loop() { 21 lcd.clear(); //d 22 delay(4000);// 23 lcd.blink(); 24 lcd.setCursor(0, 0); 25 delay(6000); //2000 26 27 for(int i=0;i<Hello.length();i++){ 28 lcd.print(Hello.charAt(i)); 29 delay(400); 30 } 31 delay(6000);//2000 32 lcd.noBlink(); 33 delay(3000); 34 lcd.clear(); 35}
Code example: lcd.lefttoRight, lcd.righttoLeft, lcd.home, lcd.display, lcd.nodisplay
arduino
1#include <LiquidCrystal.h> 2 3const int rs = 2, 4 en = 3, 5 d4 = 6, 6 d5 = 7, 7 d6 = 8, 8 d7 = 9; 9 10LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 11 12void setup() { 13 lcd.begin(16, 2); 14 Serial.begin(9600); 15} 16 17 18String Hello="Hello World!"; 19 20void loop() { 21 lcd.clear(); delay(4000); 22 lcd.setCursor(7, 0); 23 lcd.rightToLeft(); 24 lcd.print("TFEL-<"); 25 26 delay(4000); 27 28 lcd.setCursor(7, 1); 29 lcd.leftToRight(); 30 lcd.print("RIGHT->"); 31 32 delay(2000); 33 34 lcd.blink();delay(4000); 35 lcd.home();delay(4000); 36 37 lcd.noDisplay(); delay(4000); 38 lcd.display(); delay(4000); 39 lcd.clear(); delay(4000); 40 41}
Code example : lcd print, lcd.setCursor,
arduino
1#include <LiquidCrystal.h> 2 3const int rs = 2, 4 en = 5 3, 6 d4 = 6, 7 d5 = 7, 8 d6 = 8, 9 d7 10 = 9; 11 12LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 13 14void setup() { 15 16 lcd.begin(16, 2); 17 Serial.begin(9600); 18 lcd.setCursor(0, 0); 19 lcd.print("Hello 20 world"); 21}
Code example: lcd.createChar - creating single custom character
arduino
1#include <LiquidCrystal.h> 2 3const int rs = 2, 4 en = 5 3, 6 d4 = 6, 7 d5 = 7, 8 d6 = 8, 9 d7 10 = 9; 11 12LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 13 14byte bot[8] = { 15 16 0b01110, 17 0b01110, 18 0b00100, 19 0b11111, 20 0b00100, 21 0b00100, 22 23 0b01010, 24 0b10001 25}; 26 27 28void setup() { 29 lcd.begin(16, 2); 30 31 Serial.begin(9600); 32 33 lcd.createChar(0,bot); 34 lcd.clear(); 35 delay(2000); 36 37 38 39} 40 41 42 43void loop() { 44 lcd.setCursor(0, 0); 45 lcd.write(byte(0)); 46 47 delay(6000); 48 for (int j=0;j<2;j++) 49 for (int i=0;i<16;i++){ 50 51 lcd.setCursor(i, j); 52 lcd.write(byte(0)); 53 delay(100); 54 55 } 56 57 }
Code example: lcd.scroll
arduino
1#include <LiquidCrystal.h> 2 3const int rs = 2, 4 en = 3, 5 d4 = 6, 6 d5 = 7, 7 d6 = 8, 8 d7 = 9; 9 10LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 11 12 13 14void setup() { 15 lcd.begin(16, 2); 16 Serial.begin(9600); 17 lcd.clear(); 18 delay(2000); 19 lcd.print("PATREON"); 20} 21 22void loop() { 23 delay(4000); 24 for (int pos = 0; pos < 23; pos++) { 25 lcd.scrollDisplayRight(); 26 delay(250); 27 } 28 for (int pos = 0; pos < 23; pos++) { 29 lcd.scrollDisplayLeft(); 30 delay(250); 31 } 32 33}
Code example: lcd.createChar - creating composite clipart out of multiple custom characters
arduino
1#include <LiquidCrystal.h> 2 3const int rs = 2, 4 en = 5 3, 6 d4 = 6, 7 d5 = 7, 8 d6 = 8, 9 d7 10 = 9; 11 12LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 13 14byte S1[8] = { 15 16 0b00000, 17 0b00000, 18 0b00011, 19 0b00100, 20 0b01000, 21 0b01000, 22 23 0b10000, 24 0b10000 25}; 26 27byte S2[8] = { 28 0b00000, 29 0b11111, 30 31 0b00000, 32 0b00000, 33 0b00000, 34 0b11011, 35 0b11011, 36 0b11011 37}; 38 39 40byte S3[8] = { 41 0b00000, 42 0b00000, 43 0b11000, 44 0b00100, 45 46 0b00010, 47 0b00010, 48 0b00001, 49 0b00001 50}; 51 52 53byte S4[8] 54 = { 55 0b10000, 56 0b10010, 57 0b01001, 58 0b01000, 59 0b00100, 60 0b00011, 61 62 0b00000 63}; 64 65 66byte S5[8] = { 67 0b00000, 68 0b00000, 69 0b00000, 70 71 0b11111, 72 0b00000, 73 0b00000, 74 0b11111 75}; 76 77 78byte S6[8] 79 = { 800b00001, 810b01001, 820b10010, 830b00010, 840b00100, 850b11000, 860b00000 87}; 88 89void 90 setup() { 91 lcd.begin(16, 2); 92 Serial.begin(9600); 93 lcd.begin(16, 2); 94 95 96 // create a new character 97 lcd.createChar(0,S1); 98 // create a new character 99 100 lcd.createChar(1,S2); 101 // create a new character 102 lcd.createChar(2,S3); 103 104 // create a new character 105 lcd.createChar(3,S4); 106 // create a new character 107 108 lcd.createChar(4,S5); 109 // create a new character 110 lcd.createChar(5,S6); 111 112 lcd.clear(); 113 delay(3000); 114} 115 116 117 118void loop() { 119 120// set the 121 cursor to the top left 122 lcd.setCursor(0, 0); 123 lcd.write(byte(0)); 124 lcd.write((byte)1); 125 126 lcd.write((byte)2); 127 lcd.setCursor(0, 1); 128 lcd.write((byte)3); 129 130 lcd.write((byte)4); 131 lcd.write((byte)5); 132 133 }
Downloadable files
Connectivity
Connectivity
Connectivity
Connectivity
Comments
Only logged in users can leave comments
How to use LCD 1602 display with Arduino | Arduino Project Hub
Anonymous user
2 years ago
Easy! I have successfully made a "Happy Birthday" and combined buzzer with birthday song in this Ardunio