1.1K
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 } }