Controle IR Remoto Arduino 0038B
Autor: Maria e Deivson | Publicado: 2012-01-24T21:24:00-03:00

Para iniciar é muito&nbsp;fácil, basta apenas no pino que tem um "S" no sensor IR conectar na porta digital 11 do Arduíno, e logo a porta negativa que esta como um sinal de menos, e o pino positivo que possui um sinal de mais.
Após tudo instalado basta clicar no&nbsp;botão&nbsp;"Serial Monitor" do software&nbsp;Arduíno&nbsp;e testa o&nbsp;controle&nbsp;ver se esta imprimindo os valores correspondentes de cada&nbsp;botão.






Código


#include &lt;IRremote.h&gt;

int receiver = 11; // Conectar IR Receiver na porta digital 11
IRrecv irrecv(receiver); // Criar objeto 'irrecv'
decode_results results;
void setup()
{
&nbsp; Serial.begin(9600); // for serial monitor output
&nbsp; irrecv.enableIRIn(); // Start the receiver
}
void loop()
{
&nbsp; if (irrecv.decode(&amp;results)) // have we received an IR signal?
&nbsp; {
&nbsp; &nbsp;Serial.println(results.value, DEC); // Imprimir na porta serial o valor do controle
&nbsp; &nbsp;
&nbsp; &nbsp;
&nbsp; &nbsp; switch(results.value)
&nbsp; {
&nbsp; &nbsp; case 16613503: Serial.println(" Menu &nbsp; &nbsp; &nbsp;"); break;
&nbsp; &nbsp; case 16580863: Serial.println(" Power button &nbsp; "); break;
&nbsp; &nbsp; case 16597183: Serial.println(" play/pause &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "); break;
&nbsp; &nbsp;
&nbsp; &nbsp;case 16589023: &nbsp;Serial.println(" RPT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "); break;
&nbsp; &nbsp; case 16621663: &nbsp;Serial.println("CH- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "); break;
&nbsp; &nbsp; case 16605343: &nbsp;Serial.println("CH+ &nbsp; &nbsp; &nbsp; &nbsp; "); break;
&nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;case 16584943: &nbsp;Serial.println(" EQ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "); break;
&nbsp; &nbsp; case 16617583: &nbsp;Serial.println(" &nbsp;VOL - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"); break;
&nbsp; &nbsp; case 16601263: &nbsp;Serial.println("VOL + &nbsp; &nbsp; &nbsp; &nbsp; "); break;
&nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;case 16593103: &nbsp;Serial.println(" ZERO &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"); break;
&nbsp; &nbsp; case 16625743: &nbsp;Serial.println(" &nbsp;&lt;&lt;&lt;&lt;&lt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"); break;
&nbsp; &nbsp; case 16609423: &nbsp;Serial.println("&gt;&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"); break;
&nbsp; &nbsp;
&nbsp; &nbsp; case 16582903: &nbsp;Serial.println(" 1 &nbsp; &nbsp; &nbsp; &nbsp; "); break;
&nbsp; &nbsp; case 16615543: &nbsp;Serial.println(" &nbsp;2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "); break;
&nbsp; &nbsp; case 16599223: &nbsp;Serial.println("3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"); break;
&nbsp; &nbsp;
&nbsp; &nbsp; case 16591063: &nbsp;Serial.println(" 4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "); break;
&nbsp; &nbsp; case 16623703: &nbsp;Serial.println(" 5 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "); break;
&nbsp; &nbsp; case 16607383: &nbsp;Serial.println(" 6 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"); break;
&nbsp; &nbsp;
&nbsp; &nbsp; case 16586983: &nbsp;Serial.println(" 7 &nbsp; &nbsp; &nbsp; &nbsp; "); break;
&nbsp; &nbsp; case 16619623: &nbsp;Serial.println(" 8 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"); break;
&nbsp; &nbsp; case 16603303: &nbsp;Serial.println(" 9 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"); break;

&nbsp; &nbsp; default: Serial.println(" other button &nbsp; ");
&nbsp; }
&nbsp; delay(500);
&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;
&nbsp; &nbsp; irrecv.resume(); // receive the next value
&nbsp; } &nbsp;// Your loop can do other things while waiting for an IR command
}




Fonte: Ebay.com