I2C LCD and TSL2561 Light Sensor - Pins Conflict

Getting ‘re’-started with Arduino, after a long time …

I’m trying to build a Lux/Light Sensor and have the LUX value displayed on an I2C LCD screen.
I followed examples given by Adafruit and was able to run the LCD and sensor SEPARATELY. However, the two programs BOTH use Analog Pins 4&5.

To use both LCD display and LUX sensor, I need to change the PINS assignments for one of them. I lloked in both sketches and could not find where the pins are assigned. I was hoping somehow that such pins assignments would be in the main programs, but they appear to be in the ‘included’ files …

Anyone got a hint as to how I can re-assign the pins, to be able to use the LCD display AND the LUX sensor together?

Below are code fragments:

LCD Screen

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
//i2c pins
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

void setup()
{
lcd.begin(16,2);
lcd.backlight();//Power on the back light
}

void loop()
{
lcd.setCursor(0,0); //we start writing from the first row first column
lcd.print(" TSL2561 Sensor"); //16 characters per line
lcd.setCursor(0,1); //we start writing from the first row first column
lcd.print(" [Lux]"); //16 characters poer line
delay(100);//Delay used to give a dinamic effect
}

TSL2561 Sensor

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_TSL2561_U.h>

/* This driver uses the Adafruit unified sensor library (Adafruit_Sensor),
which provides a common ‘type’ for sensor data and some helper functions.

Connections

Connect SCL to analog 5
Connect SDA to analog 4
Connect VDD to 3.3V DC
Connect GROUND to common ground
*/

Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345);

// Displays some basic information on this sensor from the unified
// sensor API sensor_t type (see Adafruit_Sensor for more information)

void displaySensorDetails(void)
{
sensor_t sensor;
tsl.getSensor(&sensor);
Serial.println("------------------------------------");
Serial.print ("Sensor: "); Serial.println(sensor.name);
Serial.print (“Driver Ver: “); Serial.println(sensor.version);
Serial.print (“Unique ID: “); Serial.println(sensor.sensor_id);
Serial.print (“Max Value: “); Serial.print(sensor.max_value); Serial.println(” lux”);
Serial.print (“Min Value: “); Serial.print(sensor.min_value); Serial.println(” lux”);
Serial.print (“Resolution: “); Serial.print(sensor.resolution); Serial.println(” lux”);
Serial.println(”------------------------------------”);
Serial.println(””);
delay(500);
}

// Configures the gain and integration time for the TSL2561

void configureSensor(void)
{
tsl.enableAutoRange(true); /* Auto-gain … switches automatically between 1x and 16x */

tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS); /* fast but low resolution */

// Update these values depending on what you’ve set above
Serial.println("------------------------------------");
Serial.print ("Gain: "); Serial.println(“Auto”);
Serial.print (“Timing: “); Serial.println(“13 ms”);
Serial.println(”------------------------------------”);
}

// Arduino setup function (automatically called at startup)
void setup(void)
{
Serial.begin(9600);
Serial.println(“Light Sensor Test”); Serial.println("");

// Initialise the sensor
if(!tsl.begin())
{
/* There was a problem detecting the ADXL345 … check your connections */
Serial.print(“Ooops, no TSL2561 detected … Check your wiring or I2C ADDR!”);
while(1);
}

// Display some basic information on this sensor
displaySensorDetails();

// Setup the sensor gain and integration time
configureSensor();

Serial.println("");
}

// Arduino loop function, called once ‘setup’ is complete (your own code should go here)

void loop(void)
{
/* Get a new sensor event */
sensors_event_t event;
tsl.getEvent(&event);

/* Display the results (light is measured in lux) /
if (event.light)
{
Serial.print(event.light); Serial.println(" lux");
}
else
{
/
If event.light = 0 lux the sensor is probably saturated
and no reliable data could be generated! */
Serial.println(“Sensor overload”);
}
delay(250);
}

I2C is a bus. Meaning that several devices can be connected to the bus (SDA(A4) and SCL(A5)).

An I2C tutorial

How to combine 2 codes.

This is a common problem when combining sketches and you do not understand the hardware and or software. I suggest you get the Arduino cookbook and read it. Also on line there are many videos etc showing the Arduino and how to do what you want. This additional information will go a long way in getting your problem solved. Once you get past this you then need to select your sensors and actuators. At that point you start on the hardware design and write your software. Very important also follow groundFungus suggestions.

Thank you Gentlemen, for the answers and the references.

I guess the fact that pins A4/A5 (to which I connected SDA/SCL) are labeled 'Analog' on the board was a bit mis-leading ... I had assumed somehow they were 'regular' pins ... not a Bus. Live and Learn it is.

So then, if A4/A5 are a bus, it means I can connect multiple sensors and I can address them separately just with their ID/Address ... Correct? Yes, I have more reading I need to do.

Thank You again.