SHARE
TWEET

Untitled

a guest May 16th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <LiquidCrystal_I2C.h>
  2. #include <Wire.h>
  3.  
  4. // set the LCD number of columns and rows
  5. int lcdColumns = 20;
  6. int lcdRows = 4;
  7.  
  8. // set LCD address, number of columns and rows
  9. LiquidCrystal_I2C lcd(0x27, lcdColumns, lcdRows);
  10.  
  11. void setup()
  12. {
  13.     // initialize LCD
  14.     lcd.init();
  15.     // turn on LCD backlight
  16.     lcd.backlight();
  17.  
  18.     Wire.begin();
  19.     Serial.begin(115200);
  20.     Serial.println("\nI2C Scanner");
  21. }
  22.  
  23. void loop()
  24. {
  25.     char test[] = "Hello, World!";
  26.  
  27.     int col = 4;
  28.     // set cursor to a variable column, first row
  29.     lcd.setCursor(col, 0);
  30.     // print message
  31.     lcd.print(test);
  32.     delay(1000);
  33.     // clears the display to print new message
  34.     lcd.clear();
  35.  
  36.     lcd.setCursor(col, 1);
  37.     lcd.print(test);
  38.     delay(1000);
  39.     lcd.clear();
  40.  
  41.     lcd.setCursor(col, 2);
  42.     lcd.print(test);
  43.     delay(1000);
  44.     lcd.clear();
  45.  
  46.     lcd.setCursor(col, 3);
  47.     lcd.print(test);
  48.     delay(1000);
  49.     lcd.clear();
  50.  
  51.     int counter = char_counter(test);
  52.     Serial.println(counter);
  53.     lcd.setCursor(5, 1);
  54.     lcd.print("Line count");
  55.     delay(1000);
  56.  
  57.     lcd.setCursor(7, 2);
  58.     lcd.print("is");
  59.     delay(1000);
  60.  
  61.     lcd.setCursor(11, 2);
  62.     lcd.print(String(counter));
  63.     delay(1000);
  64.     lcd.clear();
  65. }
  66.  
  67. int char_counter(char *character_arr)
  68. {
  69.     int char_length = strlen(character_arr);
  70.     return char_length;
  71. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top