Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <unistd.h>
- #include <pigpio.h>
- #define I2C_ADDR 0x48
- int main(void) {
- if (gpioInitialise() < 0) return 1;
- int handle = i2cOpen(1, I2C_ADDR, 0);
- unsigned char value;
- char aout = 128;
- unsigned char command[2];
- command[1] = aout;
- command[0] = 0x40 | (0 & 0x03);
- while (1) {
- i2cWriteDevice(handle, &command, 2);
- usleep(2000);
- value = i2cReadByte(handle);
- printf("%d\n", value);
- // sleep(1);
- }
- i2cClose(handle);
- gpioTerminate();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement