I have to diffrenttwo different programs written for my arduinoArduino. One checks the room temperature every 5 seconds. The other one looks for IR remote signals.
I would love to combine those 2 programs, yet the problem which occurs is: The the delay from the room temperature scriptsketch.
If I would combine them. it means my IR script wontwon't be working for a full 5 seconds (because of the delay of the room temperature script) then it will be able to recievereceive a fraction of a second and then the Temperature scripttemperature sketch goes again.
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
int led = 12;
const int inPin = 0;
void setup() {
// put your setup code here, to run once:
pinMode(led, OUTPUT);
digitalWrite(led, LOW);
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop() {
// put your main code here, to run repeatedly:
int value = analogRead(inPin);
float millivolts = (value / 1024.0 ) * 5000;
float celsius = millivolts / 10;
Serial.println(celsius, 1);
delay(5000);
if(irrecv.decode(&results)) {
//this checks to see if a code has been received
{
if(results.value == 0xFF6897) {
//if the button press equals the hex value 0xC284
{
digitalWrite(led, HIGH);
// turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW);
// turn the LED off by making the voltage LOW
delay(1000); // wait for a second//do something useful here
}
irrecv.resume(); //receive the next value
}
}
}
doesDoes anyone know how to keep the IR part active and the temperature meisuremeasure every 5 seconds, and do this simultaneously.?
Or do I need another arduinoArduino?