It took me a while to get this far and I'm even further away from being done. I couldn't find a good example how to use the I2C library for it. http://wiringpi.com/reference/i2c-library/
As I understand now, the function wiringPiI2CSetup gives you a file handle (everything in linux is a file, right?) and you need to store it! That's what I'm doing with the fd variable. Ignore the broken math, it's what I got from 4 hours raging on the keyboard after hours of work. From there you can use the fileHandler thing to read and write from and to. This way I got some data from a 4x4 keyboard.
Little console helpers:
i2cget -y 1 0x20
i2cset -y 1 0x20 0x87
gpio i2cd
I also messed up the PCF8574 addressing pins :D of course I did. Here's my messy script.
#include <wiringPi.h>
#include <wiringPiI2C.h>
#include <stdio.h>
int fd;
int rpl;
int row = 1;
int col = 16;
int main (void)
{
fd = wiringPiI2CSetup(0x20);
wiringPiSetup ();
for (;;)
{
if (row>8)
{
row = 1;
col = col << 1;
if (col>128) col = 16;
}
rpl = wiringPiI2CWrite(fd, 240-col+row);
int b = wiringPiI2CRead(fd);
// printf("\t%i", 240-col);
// printf("\t%i", row);
// printf("\t%i\n", b);
if (b != 240-col+row)
{
printf("\t%i", b);
printf("\t%i\n", 240-col+row);
delay(250);
}
// delay(250);
row*=2;
}
return 0 ;
}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.