Go Down

Topic: remote control and delay problem (Read 569 times) previous topic - next topic

brraaq

I want to run for 2 minutes and shuts off for 4 minutes I add function to stop by remote control but the problem is that the remote command is not received until the end of the delay
help in modifying the code

Code: [Select]

#include <IRremote.h>
int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;
int buttonState = 0;
int lastpressed = 0;
int i = 1;

void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn();
pinMode(13, OUTPUT); 
}

void loop() {
unsigned long codeValue;
  if (irrecv.decode(&results) ) {
Serial.println (results.value, DEC) ;
 
  codeValue = results.value;
      irrecv.resume();
  }
   if (codeValue == 83579055){
   i = 1;
  }
   if (codeValue == 83570895){
   i = 0;
   }

if (i == 1){
   digitalWrite(13, HIGH);
   delay(120000); 
   digitalWrite(13, LOW);
   delay(240000); 
} else {

   digitalWrite(13, LOW);

     }

delay(10);
}


Arrch

BlinkWithoutDelay example. Learn it. Live it. Love it.

CrossRoads

Rewrite it following blink without delay methodology.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

brraaq


Arrch


I tried and I didn't succeed


That's too bad. We could probably help if we saw what you tried.

Go Up