Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

C code for 2 line x 16 char LCD

Featured Replies

This may be useful to some of you. I wrote some C code to talk to those common 2x16 LCD displays that are available in various colors from various vendors. My purpose in writing the code was to learn about the device and help document it better for other people to have an easier time using it. In my search for info, I only found poorly documented Python and Arduino code, so I thought I would write a C version and make it easy to read. You can find the code here:

 

https://github.com/bitbank2/LCD1602

 

lcd1602.jpg

2x16 I2C interface?  Interesting.  I was confused until I saw the picture, the HD44780 interface for those now has a kernel driver.  :D  I need to look at it and see if it can be run in 4-bit mode or if it has to go 8-bits wide.  I've been lazy, I have a drawer full of the parallel displays...  (good and cheap, and I'm usually using Cypress PSoC 5 controllers with tons of I/O)

  • Author
5 minutes ago, TonyMac32 said:

2x16 I2C interface?  Interesting.  I was confused until I saw the picture, the HD44780 interface for those now has a kernel driver.  :D  I need to look at it and see if it can be run in 4-bit mode or if it has to go 8-bits wide.  I've been lazy, I have a drawer full of the parallel displays...  (good and cheap, and I'm usually using Cypress PSoC 5 controllers with tons of I/O)

All of the ones I've been able to find on eBay and Aliexpress have the HD44780 paired with a simple I2C I/O expander. It just acts as a shift register and passes every write straight through to 8 data pins. The LCD can operate in 4-bit mode by sending a command of 2Xh - bit 4 sets the data bus width (see here https://learningmsp430.wordpress.com/2013/11/16/16x2-lcd-interfacing-in-4-bit-mode/). It allows having just the upper 4 data bits connected and the lower 4 bits from the I/O expander are used as control lines.

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.