I2C Addressing Statements

Hello All,

I'm doing a project where i am gathering device information along the I2C bus using i2c scanner.
What I am looking for though, is if the I2C address gets saved somewhere in memory, and that we can use the saved address for conditional statements.
For example, if a light sensor has incremental addressing from 0x16 - 0x19, can i say if(ox19 is found), printf "you have a light sensor connected"

If i need to explain more I can definitely try. All help is appreciated.
Thanks in advance,
Russell

This is the style in I2C Protocol:
1. When the scanner program has found your sensor at address 0x19 (0b0011001), then save the address in this variable: byte slaveAddress.

2. Now, execute the following codes:

Wire.beginTransmission(slaveAddress);
byte busStatus = Wire.endTrnsmission();
if(busStatus !=0 )
{
    Serial.print("Sensor is not found in I2C Bus...!");
    while(1);   //wait for ever
}
Serial.println("Senor is connected in I2C Bus.")

GolamMostafa:
This is the style in I2C Protocol:
1. When the scanner program has found your sensor at address 0x19 (0b0011001), then save the address in this variable: byte slaveAddress.

2. Now, execute the following codes:

Wire.beginTransmission(slaveAddress);

byte busStatus = Wire.endTrnsmission();
if(busStatus !=0 )
{
    Serial.print("Sensor is not found in I2C Bus...!");
    while(1);  //wait for ever
}
Serial.println("Senor is connected in I2C Bus.")

Should this be put in my setup, or in in my loop? Should be in the loop section correct? And if I want to select an individual sensor to monitor, can I call it even if the sensor is not plugged in?

In setup() function, we put those tasks that is done only for once or for a limited number of times.