Re: Using 20x4 LCD display
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 25 Oct 2021 03:57:47 UTC
"Dr. Rolf Jansen" <rj@obsigna.com> writes: >> Am 22.10.2021 um 03:52 schrieb Olivier <Olivier.Nicole@cs.ait.ac.th>: >> >> I would like to use a 20x4 LCD display attached to a Raspberry Pi >> running FreeBSd 12.2. >> >> I can talk to the display through the I2C interface, when I send >> something the back light will turn off and on, so the link is >> established. > > I use a 20x4 LCD (HD44780 type) over I2C (via PCF8574T) on a BeagleBone Black. For this, I manually transcribed one of the many Python libraries into plain C, and I wrote a minimalistic I2C glue interface in C, so it can be easily addressed. > > I just put a .zip file for downloading it on my web site: > > https://obsigna.com/Downloads/LCD_20x4_over_I2C.zip > > I added a Hello World test program (s. below). Perhaps you need to change the I2C device number and the I2C address in lcd.c. Here I have: > > uint8_t lcd_iicid = 1; > uint8_t lcd_addr = 0x27; > > The Python code contained a lot of delays between various calls. This was not necessary for the BeagleBone Black, I removed this and it let me optimize the subroutines for transferring data to the display. I don’t know whether this would work on a Raspberry Pi, though. > > Compile it with: cc i2c.c lcd.c hello.c -o hello > Run it with: ./hello > > #include <stdio.h> > #include <stdlib.h> > #include <stdint.h> > #include <unistd.h> > > #include "i2c.h" > #include "lcd.h" > > int main(int argc, const char *argv[]) > { > lcd_begin(); > lcd_print("Hello, World!", 13); > lcd_setCursor(0, 1); > lcd_print("HD44780 over PCF8574", 20); > lcd_setCursor(0, 2); > lcd_print("If it does not work,", 20); > lcd_setCursor(0, 3); > lcd_print("do not ask me why.", 18); > > return 0; > } > > Best regards > > Rolf Than you Rolf, that was very usefull. Can I use your code in a small project that I am writting and that I will put online? (project is an access control system based on user password rather than fingerprint, RFID, etc., that password is taken directly from LDAP, so one less thing to manage when users come and go). What copyright/acknoledgment should I include then? Best regards, Olivier --