materiais utilizados:
-Arduíno uno
-leds
-botão
-sensor infravermelho
-um controle
Programa:
#include <IRremote.h>
float armazenavalor;
const int RECV_PIN = 9;
const int led1 = 2;
const int led2 = 3;
const int led3 = 4;
const int led4 = 5;
const int led5 = 6;
const int led6 = 7;
const int led7 = 8;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop()
{ if (irrecv.decode(&results))
{
Serial.print("Valor lido : ");
Serial.println(results.value, HEX);
armazenavalor = (results.value);
if (armazenavalor == 0x2FD807F)
{
digitalWrite(led1, HIGH);
}
if (armazenavalor == 0x2FDC03F)
{
digitalWrite(led7, HIGH);
}
if (armazenavalor == 0x2FDA05F)
{
int i;
int T = 250;
for(i = 0; i<10; i++)
{
digitalWrite(led2, HIGH);
digitalWrite(led6, HIGH);
delay(T);
digitalWrite(led3, HIGH);
digitalWrite(led5, HIGH);
delay(T);
digitalWrite(led4, HIGH);
delay(T);
digitalWrite(led2, LOW);
digitalWrite(led6, LOW);
delay(T);
digitalWrite(led3, LOW);
digitalWrite(led5, LOW);
delay(T);
digitalWrite(led4, LOW);
delay(T);
}
}
if (armazenavalor == 0x2FD40BF)
{
digitalWrite(led1, LOW);
}
if (armazenavalor == 0x2FD20DF)
{
digitalWrite(led7, LOW);
}
irrecv.resume();
}
}
Autor: gusthavo wesley