I told him that he's using GCbasic syntax instead of PBP, and asked to fix it.
While he (she, it?) is no longer using GCBasic style subroutine calls, it now uses some C++ syntax
Code:' PICBASIC PRO code for reading voltage from ADS1115 via I2C ' Define I2C settings #IFNDEF __PCM DEFINE I2C_SDA_PORT = PIN_A0 ' Define SDA pin DEFINE I2C_SCL_PORT = PIN_A1 ' Define SCL pin #ENDIF DEFINE I2C_CLOCK 100000 ' Set I2C clock frequency to 100 kHz ' Define constants ADS1115_ADDRESS CON $48 ' I2C address of ADS1115 (A5 and A4 connected to GND) CONFIG_REG CON $01 ' Address of the configuration register CONVERSION_REG CON $00 ' Address of the conversion register ' Define variables Data_MSB VAR BYTE Data_LSB VAR BYTE ConversionResult VAR WORD Voltage VAR FLOAT ' Initialize I2C communication I2CWRITE ADS1115_ADDRESS, [CONFIG_REG, $C3, $83] ' Set configuration for continuous conversion mode ' Main loop DO ' Request a conversion I2CWRITE ADS1115_ADDRESS, [CONFIG_REG, $C3, $83] ' Start a new conversion ' Wait for conversion to complete PAUSE 50 ' Adjust the delay based on your requirements ' Read conversion result I2CREAD ADS1115_ADDRESS, [CONVERSION_REG], Data_MSB, Data_LSB ConversionResult = MAKEWORD(Data_MSB, Data_LSB) ' Process the result (assuming full-scale range is 4.096V) Voltage = ConversionResult * 4.096 / 32768.0 ' Your code to use the Voltage value as needed ' Add a delay or perform other tasks as needed PAUSE 1000 ' Adjust the delay based on your requirements LOOP



Reply With Quote
Bookmarks