SHARE
TWEET

Untitled

a guest Jan 24th, 2020 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.   LiquidCrystal Library - display() and noDisplay()
  3.  
  4.  Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
  5.  library works with all LCD displays that are compatible with the
  6.  Hitachi HD44780 driver. There are many of them out there, and you
  7.  can usually tell them by the 16-pin interface.
  8.  
  9.  This sketch prints "Hello World!" to the LCD and uses the
  10.  display() and noDisplay() functions to turn on and off
  11.  the display.
  12.  
  13.  The circuit:
  14.  * LCD RS pin to digital pin 12
  15.  * LCD Enable pin to digital pin 11
  16.  * LCD D4 pin to digital pin 5
  17.  * LCD D5 pin to digital pin 4
  18.  * LCD D6 pin to digital pin 3
  19.  * LCD D7 pin to digital pin 2
  20.  * LCD R/W pin to ground
  21.  * 10K resistor:
  22.  * ends to +5V and ground
  23.  * wiper to LCD VO pin (pin 3)
  24.  
  25.  Library originally added 18 Apr 2008
  26.  by David A. Mellis
  27.  library modified 5 Jul 2009
  28.  by Limor Fried (http://www.ladyada.net)
  29.  example added 9 Jul 2009
  30.  by Tom Igoe
  31.  modified 22 Nov 2010
  32.  by Tom Igoe
  33.  modified 7 Nov 2016
  34.  by Arturo Guadalupi
  35.  
  36.  This example code is in the public domain.
  37.  
  38.  http://www.arduino.cc/en/Tutorial/LiquidCrystalDisplay
  39.  
  40. */
  41.  
  42. // include the library code:
  43. #include <LiquidCrystal.h>
  44.  
  45. // initialize the library by associating any needed LCD interface pin
  46. // with the arduino pin number it is connected to
  47. const int rs = 12, en = 11, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
  48. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
  49.  
  50. String incomingByte = ""; // for incoming serial data
  51.  
  52. void setup() {
  53.   // set up the LCD's number of columns and rows:
  54.   lcd.begin(16, 2);
  55.   // Print a message to the LCD.
  56.   lcd.print("hello, world!");
  57.  
  58.   Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
  59.   lcd.clear();
  60. }
  61.  
  62. void loop() {
  63.  
  64.  // reply only when you receive data:
  65.   if (Serial.available() > 0) {
  66.     // read the incoming byte:
  67.     incomingByte = Serial.readString();
  68.  
  69.     // say what you got:
  70.     lcd.print("I received: ");
  71.     lcd.setCursor(0, 1); // bottom left
  72.     lcd.println(incomingByte);
  73.     lcd.setCursor(0, 0); // bottom left
  74.   }
  75.  
  76. }
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