Go Down

Topic: [SOLVED] Getting Signal when I'm supposed not to (Read 179 times) previous topic - next topic

poseido

May 27, 2016, 01:46 pm Last Edit: May 27, 2016, 03:09 pm by poseido
Hello everyone

I think this is more related to hard than to soft, sorry if I'm wrong.

the thing is that I'm working on a small project to be able to do burn-in tests on tv's, for this I need to send trough IR commands to power the tv on, change channel etc, in loops.

as a first step, I started to investigate how to send IR with my tv protocol (nec) and found a sketch:

/*
* Este sketch envia por el puerto 9 en mega (3 en uno)
* la señal de apagado de NEC (Haier)
* a un led infrarojo (conectado din resistencia
* cuando recibe una señal de 3,3 voltios por el pin 2
* FUENTE: http://alumnos.informatica.utem.cl/~srocha/control-universal-con-arduino-utilizando-un-emisor-y-receptor-infrarrojos.html
*
*/
#include <IRremote.h>

IRsend irsend;
int pinButton = 2;
int valor_button;

void setup()
{
Serial.begin(9600); //solo para verificar que se esta enviando la señal
pinMode(pinButton,INPUT); //voy a usar el pin 2 como entrada
}

void loop()
{
valor_button = digitalRead(pinButton); //que valor tiene el pin 2
if(valor_button == HIGH) //si esta en arriba entonces
{
irsend.sendNEC(0x20DF10EF,32); //envia señal de APAGADO irsend.sendNEC(0x20DF10EF,32)
Serial.println("Enviado"); // imprime por serial que fue enviado
delay(100); //espera 100 milisegundos
}

}

that's working fine for me. it's very easy, and switches off my tv.
basically what it does is that when it recives power on pin 2 (I use the 3,3v power from my arduino mega XDRuino) sends the IR trough the pin 9 (3 in arduino uno). I use a button to trigger this. (from the 3,3v to the pin 2)

works fine.

I added in series a reguilar led, so when IR signal is sent, I see the blue led flashing (no need to use my phone camera to see the ir!)

problem is that the LED flashes too much times, sometimes even without me clicking the button. I removed the button and use the wire directly form 3,3 to pin 2.. and even with the wire disconnected, sometimes it sedns a signal.


seems that somehow, the port 2 is triggered, but I do not understand why.

any hint?

thanks!

sarouje

you are reading HIGH because that button pin is kind of floating. Have look at this post http://www.gammon.com.au/forum/?id=11955
, I used Internal pullup approach, so u can avoid external resistors
Sony Arouje
http://sonyarouje.com

[Please don't send Personal Messages for any Technical question, use forum instead.]

poseido

you are reading HIGH because that button pin is kind of floating. Have look at this post http://www.gammon.com.au/forum/?id=11955
, I used Internal pullup approach, so u can avoid external resistors
Got it! I added a resistor to the imput 2 pin wire, connected to grund, and now I do not get this random flashes, neither ones I used to get when powering on the device...

Fantastic, thanks!

Go Up