8
\$\begingroup\$

I was reading this tutorial http://arduino.cc/en/tutorial/button, and I want to do the same, but with a 2 pin IR receiver LED. The problem is, the LED needs 1-2v max, or it will break. How can I use this led as an input?

http://www.aliexpress.com/item/NEW-5X-LED-Infrared-receiver-diode-IR-5mm/32224564143.html This is my ir receiver.

\$\endgroup\$
  • 4
    \$\begingroup\$ Soon, people will come and want to migrate this question to Arduino. This comment is here to tell them that this question is about electronics design and is perfectly on topic here, even though the context in which it arose is an Arduino one. \$\endgroup\$ – Keelan Mar 20 '15 at 9:25
  • 2
    \$\begingroup\$ This appears to be a arduino user-level problem. "Ardunio" was mentioned, no clear explanation in the question, wiring diagrams instead of schematics, and overall it seems this is about hooking this to that without interest in the electronics. \$\endgroup\$ – Olin Lathrop Mar 20 '15 at 13:09
  • 2
    \$\begingroup\$ @OlinLathrop there's no reason why a wiring diagram wouldn't suffice for a schematic. Not a valid close reason. \$\endgroup\$ – Keelan Mar 20 '15 at 13:26
  • 4
    \$\begingroup\$ @Camil: No, wiring diagrams have to be interpreted to infer the circuit. That is time consuming, error prone, and annoying to electrical engineers. It's a slap in the face of those who you are asking a favor of. However, that's not the close reason, other than it might contribute to unclear. This is a arduino user-level question, having very little to do with electronics. The first word of the title says it all. \$\endgroup\$ – Olin Lathrop Mar 20 '15 at 13:40
  • 10
    \$\begingroup\$ It is about using an IR receiver in place of a button. The Arduino context is irrelevant. Some users just don't know how to make a schematic. It's great they make a wiring diagram, because it's much clearer than when they simply describe the circuit. \$\endgroup\$ – Keelan Mar 20 '15 at 13:43
13
\$\begingroup\$

I fixed my problem, here is an explanation for others:

I connected one pin of the IR transistor to ground, and the other to both Analog pin 5, and to a 210 Ohm resistor leading to 5v.

Schematic

Then I used this code:

int analogPin = 5;     
int val = 0;     


void setup()
{
  Serial.begin(9600); 
}

void loop()
{
  val = analogRead(analogPin);
  delay(1);
  if(val<1000){
  Serial.println(val);
  }
}

Then if you use an IR remote, or a IR Led, the value will decrease when the signal is stronger.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.