PIC16F-6-I2C-MASTER-MAIN.C

by Marwen Maghrebi
void main(void) {
    // Configure Port D as output for LED bar
    TRISD = 0x00;
    PORTD = 0x00;

    // Initialize I2C master
    I2C_Master_Init();

    while (1) {
        I2C_Start();           // I2C Start Sequence
        I2C_Write(0x41);       // I2C Slave Device Address (0x40) + Read (1)
        PORTD = I2C_Read();    // Read data from slave and display on Port D
        I2C_Stop();            // I2C Stop Sequence
        __delay_ms(100);       // Delay 100 ms
    }
}
Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?
-
00:00
00:00
Update Required Flash plugin
-
00:00
00:00