I have a Sainsmart 20x4 LCD screen and I am currently using ports a0-a3 as inputs that captures the resistance of my 4 probes. I tried to plug in an analog Light sensor into ports a4 and a5 and now my lcd screen doesn't work.
Do we loose 2 analog ports when we use I2C in our code?
On an UNO A4 and A5 are the hardware I2C signal pins that interface with your display
The only way around this is to chnage to a library that uses software based I2C with different pins or a different Arduino board that makes more analogue lines available.
If you need to switch to using a s/w i2c to free up A4 and/or A5 then I recommend the SoftwareWire library.
It is in the Arduino IDE library manager and is super easy to use and has good performance.
The issue you will have with most i2c lcd libraries is that they include <Wire.h> so you can't just modify your sketch to use SoftwareWire instead of Wire.
You will have to modify the lcd library in order to SoftwareWire.
If you want an easier to use solution for SoftwareWire with a i2c lcd backpack, then I'd recommend using my hd44780 library.
It will "just work" if you include <SoftwareWire.h> in your sketch instead of <Wire.h> as long as you name your SoftwareWire i2c object "Wire".
The i/o class for i2c backpacks is hd44780_I2Cexp. There are examples and a diagnostic sketch (I2CexpDiag) to test the I2C pins and the internal RAM of the LCD.
The hd44780_I2Cexp class will automatically locate and self configure the pin mappings on the i/o expander chip so you don't have to fill in any of that information in the constructor.