Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FastLED.h>
- #include <IRLib.h>
- #define DATA_PIN 12
- #define CLOCK_PIN 7
- #define NUM_LEDS 61
- #define WAIT_TIME 1000
- #define COLOR_ORDER BGR
- uint8_t max_bright = 20;
- uint8_t lead_dot = 0;
- uint8_t bpm = 40;
- uint8_t voldown = 0;
- uint8_t volup = 0;
- CRGB leds[NUM_LEDS];
- IRrecv My_Receiver(11);//receiver on pin 11
- IRdecodeNEC My_Decoder;//Decoder object
- void setup() {
- delay( 3000 ); //safety startup delay
- FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, COLOR_ORDER>(leds, NUM_LEDS);
- FastLED.setBrightness(max_bright);
- My_Receiver.enableIRIn(); // Start the receiver
- Serial.begin(9600);
- }
- void loop()
- {
- // FastLED.show();fill_solid(leds, NUM_LEDS, CRGB::Black);
- if (My_Receiver.GetResults(&My_Decoder)) {
- My_Decoder.decode();
- if (My_Decoder.decode_type== NEC) {
- switch(My_Decoder.value) {
- case 0xFD00FF: //Volume Down
- volup = 0;
- voldown++;
- if(voldown > 1){
- voldown = 0;}
- // delay(1000);
- break;
- case 0xfd40bf: //volume up
- voldown = 0;
- volup++;
- if(volup > 1){
- volup = 0;}
- // delay(1000);
- break;
- }
- My_Receiver.resume(); //Restart the receiver
- }}
- if(volup == 1) { //Volume up
- leds[lead_dot].b = 255;
- lead_dot = beatsin8(bpm, 0, NUM_LEDS);
- FastLED.show();
- EVERY_N_MILLISECONDS(20) {
- fadeToBlackBy(leds, NUM_LEDS, 64);
- }
- }
- if(voldown == 1) {//Volume down
- leds[lead_dot].g = 255;
- lead_dot = beatsin8(bpm, 0, NUM_LEDS);
- FastLED.show();
- EVERY_N_MILLISECONDS(20) {
- fadeToBlackBy(leds, NUM_LEDS, 64);
- }
- }
- if(voldown == 0 && volup == 0) {//both off
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i] = CRGB::Black;
- FastLED.show();
- //updateLights(WAIT_TIME / 25);
- }}
- Serial.print(voldown);
- Serial.println();
- }
Advertisement
Add Comment
Please, Sign In to add comment