i2c and PCA9685 under raspberry

0

I am trying to turn on a series of LEDs using the integrated pca9685 but I can not get it to work. The communication by i2c works correctly but does not pay attention to the codes that I send. This is the code I use:

int LED_test()
{
    printf("     Test PWM:\n");
    bus_i2c = open("/dev/i2c-1", O_RDWR | O_NOCTTY | O_NDELAY);
    if (bus_i2c == -1)
    {
        perror(" Unable to open i2c bus ");
    }
    else
    {
        if (ioctl(bus_i2c, I2C_SLAVE, 0x39) < 0)
        {
            perror(" Unable to open PWM port ");
        }
        else
        {
            write(bus_i2c, "0xFB", 4); //ALL_LED_ON_H
            sleep(2);
            write(bus_i2c, "0xFD", 4); //ALL_LED_OFF_H
        }
    }
    close(bus_i2c);
    return 0;
}
    
asked by Quarkbite 10.07.2018 в 13:30
source

0 answers