Monday, April 16, 2018

LCD1602 I2C Source Code To Display Serial Input to LCD Output

LCD 1602 I2C Source Code To Display Serial Monitor Input to LCD Output

 

[pastacode lang="c" manual="%23include%20%3CWire.h%3E%20%2F%2F%20Arduino%20IDE%20%E5%85%A7%E5%BB%BA%0A%2F%2F%20LCD%20I2C%20Library%EF%BC%8C%E5%BE%9E%E9%80%99%E8%A3%A1%E5%8F%AF%E4%BB%A5%E4%B8%8B%E8%BC%89%EF%BC%9A%0A%2F%2F%20https%3A%2F%2Fbitbucket.org%2Ffmalpartida%2Fnew-liquidcrystal%2Fdownloads%0A%23include%20%3CLiquidCrystal_I2C.h%3E%0A%0A%2F%2F%20Set%20the%20pins%20on%20the%20I2C%20chip%20used%20for%20LCD%20connections%3A%0A%2F%2F%20addr%2C%20en%2Crw%2Crs%2Cd4%2Cd5%2Cd6%2Cd7%2Cbl%2Cblpol%0ALiquidCrystal_I2C%20lcd(0x27%2C%202%2C%201%2C%200%2C%204%2C%205%2C%206%2C%207%2C%203%2C%20POSITIVE)%3B%20%2F%2F%20%E8%A8%AD%E5%AE%9A%20LCD%20I2C%20%E4%BD%8D%E5%9D%80%0A%0Avoid%20setup()%20%7B%0ASerial.begin(9600)%3B%20%2F%2F%20%E7%94%A8%E6%96%BC%E6%89%8B%E5%8B%95%E8%BC%B8%E5%85%A5%E6%96%87%E5%AD%97%0Alcd.begin(16%2C%202)%3B%20%2F%2F%20%E5%88%9D%E5%A7%8B%E5%8C%96%20LCD%EF%BC%8C%E4%B8%80%E8%A1%8C%2016%20%E7%9A%84%E5%AD%97%E5%85%83%EF%BC%8C%E5%85%B1%202%20%E8%A1%8C%EF%BC%8C%E9%A0%90%E8%A8%AD%E9%96%8B%E5%95%9F%E8%83%8C%E5%85%89%0A%0A%2F%2F%20%E9%96%83%E7%88%8D%E4%B8%89%E6%AC%A1%0Afor(int%20i%20%3D%200%3B%20i%20%3C%203%3B%20i%2B%2B)%20%7B%0Alcd.backlight()%3B%20%2F%2F%20%E9%96%8B%E5%95%9F%E8%83%8C%E5%85%89%0Adelay(250)%3B%0Alcd.noBacklight()%3B%20%2F%2F%20%E9%97%9C%E9%96%89%E8%83%8C%E5%85%89%0Adelay(250)%3B%0A%7D%0Alcd.backlight()%3B%0A%0A%2F%2F%20%E8%BC%B8%E5%87%BA%E5%88%9D%E5%A7%8B%E5%8C%96%E6%96%87%E5%AD%97%0Alcd.setCursor(0%2C%200)%3B%20%2F%2F%20%E8%A8%AD%E5%AE%9A%E6%B8%B8%E6%A8%99%E4%BD%8D%E7%BD%AE%E5%9C%A8%E7%AC%AC%E4%B8%80%E8%A1%8C%E8%A1%8C%E9%A6%96%0Alcd.print(%22HKSTEM.CLUB%22)%3B%0Adelay(1000)%3B%0Alcd.setCursor(0%2C%201)%3B%20%2F%2F%20%E8%A8%AD%E5%AE%9A%E6%B8%B8%E6%A8%99%E4%BD%8D%E7%BD%AE%E5%9C%A8%E7%AC%AC%E4%BA%8C%E8%A1%8C%E8%A1%8C%E9%A6%96%0Alcd.print(%22TEL%3A98511356%22)%3B%0Adelay(8000)%3B%0A%0A%2F%2F%20%E5%91%8A%E7%9F%A5%E4%BD%BF%E7%94%A8%E8%80%85%E5%8F%AF%E4%BB%A5%E9%96%8B%E5%A7%8B%E6%89%8B%E5%8B%95%E8%BC%B8%E5%85%A5%E8%A8%8A%E6%81%AF%0Alcd.clear()%3B%0Alcd.setCursor(0%2C%200)%3B%0Alcd.print(%22Use%20Serial%20Mon%22)%3B%0Alcd.setCursor(0%2C%201)%3B%0Alcd.print(%22Type%20to%20display%22)%3B%0A%7D%0A%0Avoid%20loop()%20%7B%0A%2F%2F%20%E7%95%B6%E4%BD%BF%E7%94%A8%E8%80%85%E6%89%8B%E5%8B%95%E8%BC%B8%E5%85%A5%E8%A8%8A%E6%81%AF%0Aif%20(Serial.available())%20%7B%0A%2F%2F%20%E7%AD%89%E5%BE%85%E4%B8%80%E5%B0%8F%E6%AE%B5%E6%99%82%E9%96%93%EF%BC%8C%E7%A2%BA%E8%AA%8D%E8%B3%87%E6%96%99%E9%83%BD%E6%8E%A5%E6%94%B6%E4%B8%8B%E4%BE%86%E4%BA%86%0Adelay(100)%3B%0A%2F%2F%20%E6%B8%85%E9%99%A4%E8%88%8A%E8%A8%8A%E6%81%AF%0Alcd.clear()%3B%0A%2F%2F%20%E8%AE%80%E5%8F%96%E6%96%B0%E8%A8%8A%E6%81%AF%0Awhile%20(Serial.available()%20%3E%200)%20%7B%0A%2F%2F%20%E5%B0%87%E8%A8%8A%E6%81%AF%E9%A1%AF%E7%A4%BA%E5%9C%A8%20LCD%20%E4%B8%8A%0Alcd.write(Serial.read())%3B%0A%7D%0A%7D%0A%7D" message="" highlight="" provider="manual"/]

No comments: