how to manipulate the duration between LED on /off with IR remote
we can work on basic blink code as below
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
Start with learning how to read your remote. There is plenty of examples on the forum. Do a search using the box at the top of the page.
Once you can read values into your program, use them to alter the delay times.
Weedpharma
this code has updated with IR remote reading regarding Weedpharma required.
As you see from the code i declare variation of duration like oneSec or fiveSec.
but it is impossible to declare all timing
So, is there any different way to assign duration for delay from IR remote
#include <Wire.h>
#include <IRremote.h> //IRremote control
int RECV_PIN = 7; // hmc5883 compass pin attached to pin 7
IRrecv irrecv(RECV_PIN);
decode_results results;
#define oneSec 16738455
#define fiveSec 16750695
void setup()
{
irrecv.enableIRIn(); // Start the receiver
pinMode(13, OUTPUT);
pinMode(5, OUTPUT);
digitalWrite(5, HIGH);
Serial.begin(9600);
Wire.begin();
}
void loop()
{
if (irrecv.decode(&results))
irrecv.resume();
unsigned int value = results.value;
switch(value)
{
case oneSec:
{
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
break;
}
case fiveSec:
{
digitalWrite(13, HIGH);
delay(5000);
digitalWrite(13, LOW);
delay(5000);
break;
}
}
}
Declare your receive codes for all numbers 1-10.
When you press the number on the Tx, save the number in a variable. Have a timer such that if you press another number in less than 1 second it too is saved. Then convert the too digits into a value to be used in the timing loop.
Press "2" & "7".
Convert "2" to 2*10
Add 7
Your variable contains 27.
Weedpharma