Skip to content

Instantly share code, notes, and snippets.

@speendo
Created September 21, 2015 23:24
Show Gist options
  • Save speendo/0c168dc50e428e9edc91 to your computer and use it in GitHub Desktop.
Save speendo/0c168dc50e428e9edc91 to your computer and use it in GitHub Desktop.
Attempt on "Hello world!" with a 2004 LCD, I2C, PCF8574 and wiringPi
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <wiringPi.h>
#include <pcf8574.h>
#include <lcd.h>
#define i2c_adress 0x27
#define af_base 100
#define af_rs (af_base + 0)
#define af_e (af_base + 2)
#define af_db4 (af_base + 4)
#define af_db5 (af_base + 5)
#define af_db6 (af_base + 6)
#define af_db7 (af_base + 7)
#define af_backlight (af_base + 3)
int main (int argc, char *argv[])
{
int lcdHandle;
wiringPiSetupSys () ;
pcf8574Setup (af_base, i2c_adress) ;
lcdHandle = lcdInit (2, 16, 4, af_rs, af_e, af_db4, af_db5, af_db6, af_db7, 0,0,0,0) ;
pinMode(af_backlight, OUTPUT);
digitalWrite(af_backlight, HIGH);
lcdPosition (lcdHandle, 0, 0);
lcdPuts (lcdHandle, "Hello World!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment