Light sensor

Tasks:

  1. To construct a light sensor using a voltage divider configuration with a phototransistor and a resistor (with a value in the hundreds of kilohms range), you would set it up as follows:

    1. Components:
      • Phototransistor: This acts as a variable resistor whose resistance changes based on the amount of light it receives. The more light that hits the phototransistor, the lower its resistance.
      • Fixed Resistor: This is a resistor with a high resistance value, typically in the range of several hundred kilohms, to form the other half of the voltage divider.
    2. Configuration:
      • Connect one end of the phototransistor to the positive voltage supply (Vcc).
      • Connect the other end of the phototransistor to one end of the fixed resistor.
      • Connect the other end of the fixed resistor to the ground. More detailed construction of light sensor is show on video and scheme.
  2. Add also the light bulb which will help to lightning the area beneath the robot.

Mounting a light sensor.

  1. To test the light sensor and light bulb test this example code and check the reported serial data.
const int LIGHT_SENSOR_PIN = A0;

void setup()
{
  pinMode(LIGHT_SENSOR_PIN , INPUT);
  Serial.begin(9600);
}

void loop()
{
  int light_sensor_value = analogRead(LIGHT_SENSOR_PIN );
  Serial.println(light_sensor_value );
  delay(200);
}

: Ligth Sensor. {#lst:330_Ligth_Sensor}

  1. Try different resistors (1k, 10k, 100k, 1M) and find out at which the sensitivity of the sensor is greatest.
Resistance (black) Sensor value (whithe) Sensor value Sensor difference
1 kOhm      
10 kOhm      
100 kOhm      
1 MOhm      

Table: Testing the sensitivity of the light sensor. {#tbl:sensor_sensitivity}

Questions:

  1. What is the value of the sensor when the robot is over white/black area?
    • ADC value on white:
    • ADC value on black:
  2. Calculate the average between those two values.
    • Average is:

Summary:

Sensors

Sensors are electronic devices which convert physical quantity into electrical quantity (usually voltage). In simplest setup, sensor can be constructed as voltage divider with two resistors - $R_1$ and $R_2$. One of the resistors is resistor with fixed resistance value (eg. $R_1=10k\Omega$). The second one is a bit special and it's resistance depends on some physical quantity (e.g. light, temperature, humidity...). When combining those two resistors into such voltage divider the output of the voltage divider can be calculated as:

\[U_{Out} = \frac{R_1}{R_1 + R_2} U_0\]

Voltage Divider Principle

The junction between the phototransistor and the fixed resistor is where the output voltage (Vout) is measured. As the light intensity increases, the resistance of the phototransistor decreases. This causes the voltage across the fixed resistor to increase (because a smaller portion of the total voltage is dropped across the phototransistor). Conversely, when the light intensity decreases, the resistance of the phototransistor increases, causing more voltage to drop across it, and less across the fixed resistor, thus lowering Vout.

Issues:

Value of the sensor is very small

If the value of the sensor is less than 100 the resistance of $R_2$ (connected to GND) is to low in comparismant to the resistance of R_1 (connected to +5V).

Value of the sensor is large

If the value of the sensor is grater than 900 the resistance of $R_2$ (connected to GND) is to hi in comparismant to the resistance of R_1 (connected to +5V).

How to increase the sensors’ response?

To increase the response of a light sensor built using a phototransistor and a resistor in a voltage divider configuration, you can try the following strategies:

  • Fine-Tuning: Experiment with different resistor values to find the optimal balance between sensitivity and the operating range that suits your application. In general, sensors’ response will be the biggest when the output voltage will change across $V_c/2$.
  • Optimize Phototransistor Orientation and Placement: Ensure the phototransistor is optimally placed to receive the maximum amount of light from the light source. Avoid orientations where the phototransistor could be shaded or receive reflected light, which might decrease accuracy.

  • Filter and Shield from Interference:

    • Use optical filters to limit the light spectrum that reaches the phototransistor, focusing on the wavelengths of interest. This can help in applications where specific types of light need to be detected.
    • Shield the sensor from ambient light or other light sources that might cause interference, ensuring that only light from the target source impacts the sensor’s readings.