Ok, so I worte in a while back to figure out how to transmit using an IR LED to control my tv. I figured that out thanks to you guys and I am almost done with my project, but have encountered a strange occurrence. Essentially I am using a button to send the desired signal, and the code is working and my circuit is functioning as the code dictates. But I can get it to detect input merely by hovering my hand near the wires leading to my button. This is causing a false input and sending the signal even when I haven't press the button.
How do I stop this or prevent this from happening?
That is a picture of the project, I will wire and alse code for more buttons once the false input is gone.
As for a wiring diagram:
IR LED- Negative to GND and Positive to Digital Pin 3.
Blue Led(for visual feedback of IR transmission) - Positive to Digital Pin 3 and Negative to GND.
IR Decoder- GND to GND and Positive to 3V3 and Out to Digital Pin 2.
The Button- One side to Digital Pin 4 (input) and the other side has a 5V connection and a GND via 10K resistor connection.
The Button is wired the way I learned when I learned the debounce code for button inputs.
The resistor should be wired directly to the Arduino input (or to the switch terminal that goes to the Arduino).
The Digital Read Serial Example shows how to wire a pull-down resistor. The resistor holds the input low. When the switch (button) is closed the resistor is "overpowered" and the input is forced high (and current flows through the resistor).
It's actually easier to enable the the built-in internal pull-up resistor and then wire the switch to ground. That way you don't have to add a resistor. (Of course, you have to reverse the logic in your software.)
The IR Decoder is a TSOP4838. I am using the Arduino Nano's 3V3 to supply power to the decoder since it doesn't need full 5V.
My dad taught me to be mindful of circut voltages on model railroad stuff, so I am always careful to never supply anything more then 5Vs around the Arduino.
That was it, I moved the ground to the switch over to the input side and set my pin for INPUT_PULLUP and now I am not getting that false input reading if my hand gets to close.
I have several books that I picked up last week on Arduino and common circuitry. I am going to be using one of them which details schematic symbols like those in the photo you sent and many I hadn't seen before to start drawing my own schematics. I know an actual diagram is much easier to assess then a verbal wiring description. I appreciate your help.
As a follow-up question, which is better since it works fine both ways: using the 5V or using the 3V3?
That makes sense and I understand it, but now... An Arduino Nano V3.0 with ATmega 328, which is what I use, has a 5V pin and a 3V3 pin. If it is a 5V Arduino then why is it reading that IR Decoder powerd via 3V3 properly, if it's expecting 5V back? Does this Nano read both 5V and 3V3 or am I missing something?
Oh, wait "0v to 5v" includes 3v3, so technically it is within the range, right and that's why it's readingthe Decoder? Not like on a "0v to 3v3" and trying to read a 5v input which would likely fry it.