Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h> //Include LCDs Library
- #include <string.h>
- LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //Attach LCDs and Arduino pin comunnication
- short int time; //Entire variable declaration(time)
- short int col = 20, row = 4, i, j;
- byte customChar0[8] = {
- 0b11111,
- 0b11110,
- 0b11110,
- 0b11100,
- 0b11100,
- 0b11000,
- 0b11000,
- 0b10000
- };
- byte customChar1[8] = {
- 0b11111,
- 0b00000,
- 0b00000,
- 0b11011,
- 0b11011,
- 0b00000,
- 0b00000,
- 0b01110
- };
- byte customChar2[8] = {
- 0b11111,
- 0b01111,
- 0b01111,
- 0b00111,
- 0b00111,
- 0b00011,
- 0b00011,
- 0b00001
- };
- byte customChar3[8] = {
- 0b10000,
- 0b11000,
- 0b11000,
- 0b11100,
- 0b11100,
- 0b11110,
- 0b11110,
- 0b11111
- };
- byte customChar4[8] = {
- 0b00100,
- 0b00000,
- 0b00000,
- 0b10001,
- 0b01010,
- 0b00100,
- 0b00000,
- 0b11111
- };
- byte customChar5[8] = {
- 0b00001,
- 0b00001,
- 0b00011,
- 0b00011,
- 0b00111,
- 0b00111,
- 0b01111,
- 0b11111
- };
- char message [512];
- short int set_start_point (char *messg) {
- short int val1 = 0, val2 = 0, mssg_len = 0;
- mssg_len = strlen (messg);
- val1 = col - mssg_len;
- return val2 = val1 / 2;
- }
- void setup(){
- lcd.createChar(0, customChar0);
- lcd.createChar(1, customChar1);
- lcd.createChar(2, customChar2);
- lcd.createChar(3, customChar3);
- lcd.createChar(4, customChar4);
- lcd.createChar(5, customChar5);
- lcd.begin(20, 4);
- for (i = 0; i <= 2; i++){
- lcd.setCursor (8 + i, 2);
- lcd.write (byte (i));
- }
- for (j = 3; j <= 5; j++){
- lcd.setCursor (5 + j, 3);
- lcd.write (byte (j));
- }
- }
- void loop(){
- strcpy (message, "Hello Smile!");
- lcd.setCursor(set_start_point (message), 0); // Set cursor to correct position
- lcd.print (message);
- strcpy (message, "Elapsed Time:");
- lcd.setCursor(set_start_point (message), 1); // Set cursor to correct position
- lcd.print (message);
- lcd.setCursor(set_start_point (message) + strlen (message), 1); // Set cursor to correct position
- lcd.print(time); // Write the current value of the count variable in the LCD
- delay(1000); // Waits for 1 second
- time++; // Increment count variable
- if(time == 10){
- time = 0; //... resets the count variable
- lcd.clear ();
- for (i = 0; i <= 2; i++){
- lcd.setCursor (8 + i, 2);
- lcd.write (byte (i));
- }
- for (j = 3; j <= 5; j++){
- lcd.setCursor (5 + j, 3);
- lcd.write (byte (j));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement