4 Send address and byte to switch lines on 8 line port of i2c bus PCF8574
5 -----------------------------------------------------------------------
7 1) send the i2c address
8 2) send byte to set the 8 port lines on or off
10 usage :- type with spaces but without the < >
11 <PCF8574_addr_byteout.c> <address as decimal> <byte out value as decimal 0-255>
18 #include <sys/ioctl.h>
19 #include <linux/i2c.h>
25 int main(int argc, char** argv)
27 if (argc != 3) /* error if we are not getting just 2 inputs after the program name */
29 printf("Error. usage: %s i2c_chip_address byte_to_send_out\n", argv[0]);
32 /* address is the first number after the program name */
33 address = atoi(argv[1]);
35 /* the byte to send out to the PC8574 is the second number */
37 /* place it into the first element of the buf array */
38 buf[0] = atoi(argv[2]);
40 i2c = open("/dev/i2c/0",O_RDWR); /* open the device on i2c-bus number 0*/
42 ioctl(i2c,I2C_SLAVE, address); /* set the i2c chip address */
44 write(i2c,buf,1); /* send the byte */