Skip to content

Instantly share code, notes, and snippets.

@dkrkamesh
Last active April 22, 2019 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dkrkamesh/fa1b8487ccc0134613812881730d5793 to your computer and use it in GitHub Desktop.
Save dkrkamesh/fa1b8487ccc0134613812881730d5793 to your computer and use it in GitHub Desktop.
Display the heart rate data on I2C type 16x2 LCD
#include <Wire.h> // Comes with Arduino IDE
#include <LiquidCrystal_I2C.h>
// Initialize the object with interfacing pins
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
void setup()
{
Serial.begin(9600); // Initialize serial communication at 9600 baudrate
lcd.begin(16,2); // Initialize 16X2 LCD and turn on backlight
lcd.backlight();
lcd.setCursor(0,0); // Set cursor to column 1, line 1
lcd.write(" 16x2 character ");
lcd.setCursor(0,1); // Set cursor to column 1, line 2
lcd.write(" I2C LCD ");
delay(2000); // Display for sometime
lcd.noBacklight(); // Turn off backlight
delay(2000); // Turn on backlight again after sometime
lcd.backlight();
lcd.clear(); // Clear the display
lcd.setCursor(0,0);
lcd.write("Use Serial Monitor");
lcd.setCursor(0,1);
lcd.write("Type to display");
}
void loop() // Setup - Runs continuously
{
if(Serial.available()) // True if any character has arrived
{
lcd.clear(); // Clear the display
while (Serial.available() > 0)
{
lcd.write(Serial.read()); // Display all the characters on LCD
}
}
}
@randolfagbai
Copy link

These initializations line 3 was missing. POSITIVE was not also declared. This code can,t compile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment