loading
1Comments

Tell us about yourself!

Complete Your Profile
  • MarinoF commented on cyragia's instructable Fading RGB LED (Arduino)11 months ago
    Fading RGB LED (Arduino)

    So i'm making an rgb led that is controlled by an IR remote and I intend to use your wonderful code as one of the functions. My problem is that after its faded for a while and stops when I want it to stop, it doesn't resume receiving IR signals. I've had my Arduino Uno R3 for about a week now, and have only very little knowledge in C, although I've worked with some other languages before. Here is the code im using, any help would be greatly appreciated. #include <IRremote.h>int RECV_PIN = 7;IRrecv irrecv(RECV_PIN);decode_results results;int redPin = 11;int greenPin = 10;int bluePin = 9;#define delayTime 20void setup(){ Serial.begin(9600); pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); irrecv.enableIRIn();}int redVal;int blueVal;int greenVal;void...see more »So i'm making an rgb led that is controlled by an IR remote and I intend to use your wonderful code as one of the functions. My problem is that after its faded for a while and stops when I want it to stop, it doesn't resume receiving IR signals. I've had my Arduino Uno R3 for about a week now, and have only very little knowledge in C, although I've worked with some other languages before. Here is the code im using, any help would be greatly appreciated. #include <IRremote.h>int RECV_PIN = 7;IRrecv irrecv(RECV_PIN);decode_results results;int redPin = 11;int greenPin = 10;int bluePin = 9;#define delayTime 20void setup(){ Serial.begin(9600); pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); irrecv.enableIRIn();}int redVal;int blueVal;int greenVal;void loop() {if (irrecv.decode(&results)) {Serial.println(results.value, DEC);if (results.value == 16724175){setColor(255, 0, 0);}if (results.value == 16718055){setColor(0, 255, 0);}if (results.value == 16743045){setColor(0, 0, 255);}if (results.value == 16738455){setColor(0, 0, 0);}if (results.value == 16748655){setColor(255, 255, 255);}if (results.value == 16761405) {int redVal = 255; int blueVal = 0; int greenVal = 0; for( int i = 0 ; i < 255 ; i += 1 ){ greenVal += 1; redVal -= 1; analogWrite( greenPin, 255 - greenVal ); analogWrite( redPin, 255 - redVal ); delay( delayTime ); } redVal = 0; blueVal = 0; greenVal = 255; for( int i = 0 ; i < 255 ; i += 1 ){ blueVal += 1; greenVal -= 1; analogWrite( bluePin, 255 - blueVal ); analogWrite( greenPin, 255 - greenVal ); delay( delayTime ); } redVal = 0; blueVal = 255; greenVal = 0; for( int i = 0 ; i < 255 ; i += 1 ){ redVal += 1; blueVal -= 1; analogWrite( redPin, 255 - redVal ); analogWrite( bluePin, 255 - blueVal ); delay( delayTime ); } }irrecv.resume();}}void setColor(int red, int green, int blue){ analogWrite(redPin, red); analogWrite(greenPin, green); analogWrite(bluePin, blue); }

    View Instructable »