Other types of digital sensors

Switches are perhaps the most used devices as digital input sensors but obviously not the only ones. Any device that can open or close a circuit branch can be easily configured and connected to Arduino to act like a digital input sensor, from a reed relay (http://en.wikipedia.org/wiki/Reed_relay) to a PIR motion detector (http://en.wikipedia.org/wiki/Passive_infrared_sensor).

One of those devices that are very cheap and easy to acquire are optocouplers or, as they are sometimes referred to, optical switches.

An optocoupler is a very simple device that has two parts:

  • An infrared light emitter: This is a simple infrared LED in a housing that directs its light emission in a precise direction
  • A phototransistor: This is a special kind of transistor whose base is activated by the reception of light, infrared light in this case, and also in a special case that ensures that the phototransistor gets excited only with light coming from a concrete direction—that of the infrared LED on the other part of the housing

In the following couple of images, you can see the schematic of the internal structure of a typical optocoupler and a real picture of the one I used for my own assembly of the next project:

Other types of digital sensors

The internal structure of an optocoupler and a real one

If you take a closer look at the picture, you may even notice the indications on the plastic housing of the emitter part with its diode sign to reference the anode and cathode and the collector and emitter markings on the phototransistor part.

If we connect the phototransistor part to our Arduino board, we could easily detect whether it is being excited or not, thus indicating whether there is something placed just in the middle of the plastic housing or not.

This was the same principle that used the first mechanical computer mice to detect and count the X and Y movement, and for that, they used a very recognizable small slotted wheel that allowed for its internal microcontroller to account for every step the mouse took in every axis.

Note

If you are too young, perhaps you have never seen one of this kind of mice, but you could take a look at the Wikipedia entry for mouse under the Mechanical mice section at http://en.wikipedia.org/wiki/Mouse_(computing).

In the next example, we will use an optocoupler as a light barrier that when interrupted, triggers a digital input.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.140.249.104