#include <IRremote.h>
int sensor = 2;
IRrecv ip(sensor);
decode_results results;
int zpin = 3;
int gPin = 8;
bool rState = false;
void setup()
{
Serial.begin(9600);
pinMode(gPin, OUTPUT);
attachInterrupt(digitalPinToInterrupt(zpin), trig_ISR, FALLING);
attachInterrupt(digitalPinToInterrupt(sensor), ir_ISR, LOW);
ip.enableIRIn();
pinMode(sensor, INPUT);
}
void loop()
{
}
void ir_ISR()
{
rState = !rState;
}
void trig_ISR()
{
if (rState == true)
{
delayMicroseconds(4000);
digitalWrite(gPin, LOW);
delayMicroseconds(1);
digitalWrite(gPin, HIGH);
delayMicroseconds(10);
digitalWrite(gPin, LOW);
}
}
0 Comments