What is a light sensor?

From ROBOTC API Guide
Jump to: navigation, search


Light Sensors

A Light Sensor is something that a robot can use to detect the current ambient light level - i.e. how bright/dark it is. There are a range of different types of light sensors, including 'Photoresistors', 'Photodiodes', and 'Phototransistors'. The sensor included in the BoeBot kit, and the one we will be using, is called a Phototransistor.

A phototransistor.

To understand what a phototransistor is, we must first determine what a transistor is.

Basically, a regular transistor is an electrical component that limits the flow of current by a certain amount dependent on current applied to itself through another pin - so there is the collector, emitter, and 'base', which controls how much current can pass through the collector through to the emitter.

Circuit diagram of a transistor.

A phototransistor, on the other hand, uses the level of light it detects to determine how much current can pass through the circuit. So, if the sensor is in a dark room, it only lets a small amount of current through. If it detects a bright light, it lets a larger amount of current through.

Circuit diagram of a phototransistor.

We can utilize the phototransistor's unique properties by plugging it into an Analog Port.

What is Analog?

As of now, you have only used the board's Digital ports, which can accept either a 0 (a value of 0 volts) or a 1 (a value of 5 volts) as input, and give the same as output (PWM just cycles this on and off very quickly). Analog ports, on the other hand, can accept an infinite range of values between 0 volts and 5 volts. This means that our robot can translate these into meaningful sensory input that can convey far much more data. In the case of the phototransistor, this means that we can tell not only if it is 'dark' or 'light', but all the values in between. This is vitally important for an application like this, and indeed, for many sensors.

Photoresistors

There may be a time you find yourself using a photoresistor. A photoresistor operates similarly to a phototransistor however it changes its resistance based on the amount of light that falls upon it. Photoresistors tend to be less sensitive, also.

A photoresistor.