Friday, August 29, 2014

Read from Arduino Serial port, and write to 2x16 LCD

Read from Serial port of Arduino Uno, and write it to 2x16 LCD module.



/*

  http://arduino-er.blogspot.com/

  Example of using 16x2 LCD display
  Read from Arduino Serial port, and write to 2x16 LCD

 */

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
  
  Serial.begin(9600);
}

void loop() {
  if(Serial.available()){
    lcd.setCursor(0, 1);
    lcd.print("                ");
    delay(100);
    lcd.setCursor(0, 1);
    while(Serial.available() > 0){
      lcd.write(Serial.read());
    }
  }
}


Connection, refer:
Hello World of Arduino Uno + 2x16 LCD
- LED Backlight of 2x16 LCD Module

No comments:

Post a Comment