IYXH

Life is fantastic

Reading an H21A optical interruptor switch using an Arduino UNO - The simple way that really works

Rédigé par Alain Sanguinetti Aucun commentaire

About the Arduino and the H21A optical interruptor switch

Arduino is an open electronics development platform. It is widely used to power electronics projects. There are several boards that feature different capabilities. In my case, I am using an Arduino R3.

The H21A optical interruptor switch is a common piece of hardware. It is composed of an IR led and a photoresistor.

My goal is to use an Arduino to detect when the light is interrupted. As I am a newcomer to electronics and arduino, I started by looking on the internet for information on how to connect the two.

Some examples found on the internet

I found this search result to be relevant : http://www.electroschematics.com/10494/arduino-optical-position-rotary-encoder/

However, it did not worked, maybe because I did not had the recommended resistors at hand.

My solution

The solution that I found to be working is to simply connect the output pin of the H21A to a digital input pin of the Arduino. The trick is to declare the pin as "INPUT_PULLUP", this removes the need for a pull-up resistor ! :-)

Hope this helps !

Fil RSS des articles

© 2017 - Alain Sanguinetti

Site édité par Société Sanguinetti d’Informatique et d’Innovation - EIRL
241 rue de Charenton, Esc. B Appt 3D, 75012 PARIS
SIRET: 800 319 279 00025
Courriel: services@sanguinetti.eu
Tél: +33 7 70 03 56 46
Responsable de la publication : M. Sanguinetti
TVA non applicable, article 293 B du CGI

Site hébergé par OVH
2 rue Kellermann 59100 Roubaix
Tél. : +33 9 72 10 10 07