What I’m trying to do is when I hit power on my remote it goes to the strobe effect.
Both sketches work independently. I can turn an led on and off using power button with my remote and the strobe effect works but I just can’t get the two sketches combined
sketch 1. The remote sketch
/*
source: www.electroschematics.com
You'll need to change the led pins and the codes
accordingly to your configuration and IR remote
*/
#include
int RECV_PIN = 12; // the pin where you connect the output pin of IR Receiver
int itsONled[] = {0,0,0,0,0};
/* the initial state of LEDs is OFF (zero)
the first zero must remain zero but you can
change the others to 1's if you want a certain
led to light when the board is powered */
#define code1 41565 // code received from Power Button
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
irrecv.enableIRIn(); // Start the receiver
pinMode(ledPin, OUTPUT);
}
void loop() {
if (irrecv.decode(&results)) {
unsigned int value = results.value;
switch(value) {
case code1:
if(itsONled[1] == 1) { // if first led is on then
digitalWrite(ledPin, LOW); // turn it off when button is pressed
itsONled[1] = 0; // and set its state as off
} else { // else if first led is off
digitalWrite(ledPin, HIGH); // turn it on when the button is pressed
itsONled[1] = 1; // and set its state as on
}
break;
}
irrecv.resume(); // Receive the next value
}
}
STROBE. Sketch. 2. The strobe and or fade
int cycle=75;
int strobe=cycle*20; // calculate strobe delay
int maxFade=75; // maximum brightness before strobe
int ledPin = 11; // Led connected to digital pin 11
int fadeValue;
void setup() {
// nothing happens in set
}
void loop() {
// fade in from min to max in increments of 2 points:
for (int fadeValue = 0 ; fadeValue <= maxFade; fadeValue += 2) {
// sets the value (range from 0 to maxFade):
analogWrite(ledPin, fadeValue);
// wait for "cycle" milliseconds to see the dimming effect
delay(cycle);
}
analogWrite(ledPin, 255); // simulate a rotating beacon catching your eye
delay(strobe); // hold full brightness for strobe delay
analogWrite(ledPin, maxFade);
// fade out from maxFade to min in increments of 2 points:
for (int fadeValue = maxFade ; fadeValue >= 0; fadeValue -= 2) {
// sets the value (range from 0 to maxFade):
analogWrite(ledPin, fadeValue);
// wait for "cycle" milliseconds to see the dimming effect
delay(cycle);
}
}