I am quite new to the idea of programming on arduino.
The code i am using is supposed to take IR signals from a generic remote and act based on the button pressed.
#include <IRremote.h>
int IRpin = 11; // pin for the IR sensor
int ledPins[] = {9, 12, 10, 13 }; // an array of pin numbers to which LEDs are attached
int pinCount = 4; // the number of pins (i.e. the length of the array)
int brightness = 0; //How bright the LED is
int fadeAmount = 5; //How many points to fade LED by
int timer = 60; // The higher the number, the slower the timing.
IRrecv irrecv(IRpin);
decode_results results;
boolean LEDon = true; // initializing LEDon as true
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
pinMode(ledPins[thisPin], OUTPUT);
}
}
void loop()
{
if (irrecv.decode(&results))
{
irrecv.resume(); // Receive the next value
}
switch(results.value)
{
case 2534850111:
// do this
for(int i=0; i<10; i++)
analogWrite(ledPins[i], brightness); //Set brightness of RedLED1
brightness = brightness + fadeAmount; //Change brightness for nex time through loop
if (brightness == 0 || brightness == 200){ // reverse the direction of the fading at the ends of the fade:
fadeAmount = -fadeAmount;
}
delay(200);
case 163591017:
// do another thing
digitalWrite(ledPins[13], HIGH);
break;
case 3810010651:
// do another thing
digitalWrite(ledPins[13], LOW);
case 1033561079:
// feed my dog for me
digitalWrite(ledPins[9], HIGH);
digitalWrite(ledPins[10], HIGH);
digitalWrite(ledPins[12], HIGH);
digitalWrite(ledPins[13], HIGH);
delay(100);
digitalWrite(ledPins[10], LOW);
digitalWrite(ledPins[12], LOW);
digitalWrite(ledPins[13], LOW);
delay(100);
digitalWrite(ledPins[9], LOW);
digitalWrite(ledPins[10], LOW);
digitalWrite(ledPins[12], LOW);
digitalWrite(ledPins[13], LOW);
default:
for (int thisPin = 0; thisPin < pinCount; thisPin++) {
digitalWrite(ledPins[thisPin], LOW);
}
}
}
This code worked on a smaller scale but does not seem to work now.
Can you tell what i am doing wrong.