DogFlu66
Member
Library: I2C_Scan.bas – I2C Device Scanner for PIC18 (Oshonsoft)
This library scans the I2C bus for connected devices using a PIC18 microcontroller and the Oshonsoft Basic compiler. It requires the I2CLib.bas library (which provides START_I2C, STOP_I2C, WRITE_I2C) and a properly initialized serial output (UART by default) to display results.
How it works:
This library scans the I2C bus for connected devices using a PIC18 microcontroller and the Oshonsoft Basic compiler. It requires the I2CLib.bas library (which provides START_I2C, STOP_I2C, WRITE_I2C) and a properly initialized serial output (UART by default) to display results.
How it works:
- The I2C_Ping function sends a write request to a given 7-bit I2C address. If the device responds with ACK, it's considered present.
- The I2C_Scan function loops through valid I2C addresses (0x03 to 0x77), calls I2C_Ping for each, and prints the detected addresses via UART1. It also returns the total number of detected devices.