False Input or a ghost

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?

Probably a floating input. Use input pull-up in pinmode and wire your button to connect the pin to ground when pressed.

Hi, @tigerfarm1

It would be good for you to show your sketch and the schematic of your project.

RV mineirin

And an image.

Post an image of your project.

IR_TV.ino (2.2 KB)

That is my code.

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.

there isn't one

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.)

You need a series dropping resistor with the LED.

You need a series dropping resistor with the LED.

Is this a 5v Arduino ?

Wire as per S3 below then look for a LOW when the switch is pushed.
Remember to turn on the pullup for the switch pin.

1 Like

This is a 5V circuit, the 3V3 was for the decoder I used to get my IR Address and Command data.

I used a verbal description, I know how to make a diagram but I have never done it.

We need to know what the decoder is ?

The inputs to the Arduino should be 0V to 5V if the Arduino is a 5v Arduino.

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.

I am sorry I forgot to label that. The IR LED has a pre-wired 200ohm resistor and the Blue LED has a pre-wired 100ohm resistor.

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.

A TSOP4838 can be connected to 5v on its Vcc (Vs) pin.

You should really learn about making schematics; drawing them on paper is fine.

https://learn.sparkfun.com/tutorials/how-to-read-a-schematic/all

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?

The logic levels going to an input needs to match what the controller expects.

Since your controller is a 5v Arduino, the logic levels it expects are 0v to 5v, not 0v to 3.3v.

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.

Not saying the Arduino won’t work at 3.3v levels on an input, however, 3.3v gets close to the voltage that is an indeterminate level.

Notice the 5v CMOS acceptable logic voltages on the left most graph.

The important thing here is, when the controller is powered by 5v, use 5v logic input levels.

When the controller is powered by 3.3v, use 3.3v logic input levels.