Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Arduino.h>
- /**************************************************
- *
- * 5/A0 PB5 reset |1 8| Vcc
- * 3/A3 PB3 |2 7| sck PB2 2/A1
- * 4/A2 PB2 |3 6| miso PB1 1
- * GND |4 5| mosi PB0 0
- * ATtiny85
- *
- **************************************************/
- #include <FastLED.h>
- #define LED_PIN 0
- #define COLOR_ORDER RGB
- #define CHIPSET WS2811
- #define NUM_LEDS 1
- CRGB leds[NUM_LEDS];
- CRGBPalette16 currentPalette;
- TBlendType currentBlending;
- void setup()
- {
- delay(500); // sanity delay
- PORTB = 0b00000110; // pull-up on PB2 PB1
- currentPalette = RainbowColors_p;
- FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
- }
- uint8_t i=0;
- void loop()
- {
- uint16_t pot1, pot2;
- uint8_t mode;
- pot1 = analogRead(3);
- pot2 = analogRead(2);
- // switch on PB2 PB1
- mode = (PINB & 0b00000110) >> 1;
- switch (mode)
- {
- case 0: // hue and saturation
- leds[0] = CHSV( pot1/4, pot2/4, 255 );
- break;
- case 1: // sweep intensity
- leds[0] = CHSV( pot1/4, 255, cubicwave8(i));
- break;
- case 2: // sweep saturation
- leds[0] = CHSV( pot1/4, cubicwave8(i), 255);
- break;
- case 3:
- switch (pot1/128)
- {
- case 0:
- currentPalette = RainbowColors_p;
- currentBlending = LINEARBLEND;
- break;
- case 1:
- currentPalette = RainbowStripeColors_p;
- currentBlending = LINEARBLEND;
- pot2 = 1024+pot2*8;
- break;
- case 2:
- currentPalette = RainbowStripeColors_p;
- currentBlending = LINEARBLEND;
- break;
- case 3:
- currentPalette = CloudColors_p;
- currentBlending = LINEARBLEND;
- break;
- case 4:
- currentPalette = PartyColors_p;
- currentBlending = LINEARBLEND;
- break;
- case 5:
- currentPalette = OceanColors_p;
- currentBlending = LINEARBLEND;
- break;
- case 6:
- currentPalette = LavaColors_p;
- currentBlending = LINEARBLEND;
- break;
- case 7:
- currentPalette = ForestColors_p;
- currentBlending = LINEARBLEND;
- break;
- default:
- break;
- }
- leds[0] = ColorFromPalette( currentPalette, i, 255, currentBlending);
- break;
- default:
- break;
- }
- i++;
- FastLED.show(); // display this frame
- if (mode != 0)
- {
- FastLED.delay(pot2/8);
- }
- else
- {
- FastLED.delay(50);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement