2 deleted 157 characters in body; edited title
source | link

delay Delay a part of the void loop

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?

delay a part of the void loop

I have to diffrent programs written for my arduino. 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 delay from the room temperature script.

If I would combine them. it means my IR script wont be working for a full 5 seconds (because of the delay of the room temperature script) then it will be able to recieve a fraction of a second and then the Temperature script 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
}
 
}

does anyone know how to keep the IR part active and the temperature meisure every 5 seconds, and do this simultaneously.

Or do I need another arduino?

Delay a part of the void loop

I have two different programs written for my Arduino. 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 is the delay from the room temperature sketch.

If I would combine them. it means my IR script won't be working for a full 5 seconds (because of the delay of the room temperature script) then it will be able to receive a fraction of a second and then the temperature 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() {
  pinMode(led, OUTPUT);
  digitalWrite(led, LOW);
  Serial.begin(9600);
  irrecv.enableIRIn();
}

void loop() {
  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
  }
}

Does anyone know how to keep the IR part active and the temperature measure every 5 seconds, and do this simultaneously?

Or do I need another Arduino?

1
source | link

delay a part of the void loop

I have to diffrent programs written for my arduino. 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 delay from the room temperature script.

If I would combine them. it means my IR script wont be working for a full 5 seconds (because of the delay of the room temperature script) then it will be able to recieve a fraction of a second and then the Temperature script 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
}

}

does anyone know how to keep the IR part active and the temperature meisure every 5 seconds, and do this simultaneously.

Or do I need another arduino?