HUM: PHOTOINTERRUPTER

You are a beginner with Dasduino. Or electronics? A specific module caught your eye, but you do not know how to use it? Do not worry, HUM is here for you! How to Use Module (HUM) is a blog tutorials series by soldered where you will find all you need in order to begin working with your favorite module. Tutorials include: technical characteristics, work principle, instructions on how to connect the module with Dasduino and the basic code. Everything else is left to your imagination.
INTRODUCTION
You have certainly seen a revolution counter or a sensor that detects passing objects many times, and you did not know how they work. We will introduce you to a sensor frequently used for these two applications, as well as many others. For starters, this is a photointerrupter ITR9608 that can detect an object inside it. Its use is simple, and the opportunities it provides are various and we can use it in different projects.
Sensor characteristics:
- Diode voltage: 1.5V
- Diode current: 50mA
- Maximum transistor collector-emitter voltage: 30V
- Maximum transistor emitter-collector voltage: 5V
- Maximum transistor current: 20mA
HOW DOES IT WORK?
The photointerrupter has an IR diode that constantly emits light towards a phototransistor that is calibrated for that light only. The diode is located on one side of the sensor and the phototransistor on the other, and between them, there is a gap through which objects can pass. When there is no object, the phototransistor receives light from the IR diode and it is in the open (conductive) state, but when there is an object between the IR diode and the phototransistor then the phototransistor is in the closed state. If we connect a phototransistor to Dasduino, we can read when the transistor conducts current and when not to find out if there is an object between the IR diode and the phototransistor. Using this sensor, we can count objects or use them to get a simple revolution counter.
HOW TO CONNECT IT?
The sensor is easily connected to Dasduino because we only have a phototransistor that we connect to Dasduino, and we connect the IR diode to the power supply as well as the classic LED diode. The IR diode must be illuminated constantly and therefore be connected to the power supply via a resistor of the appropriate value (150-200Ω) to limit the current passing through the diode. We connect the phototransistor to the power supply as a switch, but via the resistor of higher value (10kΩ or more) and from the collector we connect the signal to the Dasduino pin in order to read when the phototransistor conducts current and when not. On the sensor, there is a labeled side indicating the location of the IR diode and the other side indicating the location of the phototransistor, and in the image, we can see the labels of the pins.
DASDUINO CODE
The first example of the code can be used for counting various objects passing through the sensor.