Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //----------------------------------------------------
- // sprocket2cog 2015 cc
- // Radar scope animation code 1.1
- // thanks to the arduino and fastled community
- //----------------------------------------------------
- #include "FastLED.h"
- #define DATA_PIN 6
- #define CHIPSET WS2812B
- #define COLOR_ORDER GRB
- #define NUM_LEDS 64
- #define BRIGHTNESS 255
- CRGB leds[NUM_LEDS];
- const uint8_t MatrixWidth = 8;
- const uint8_t MatrixHeight = 8;
- int x=0;
- int c0 = 96; //hue value for centre of radar
- int c1 = 0; //hue value for the radar sweep
- void setup() {
- FastLED.addLeds<CHIPSET, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
- LEDS.setBrightness(BRIGHTNESS);
- }
- void loop() {
- uint8_t blur = beatsin8(60,30,60); // the variable for the 2d blur effect
- int pulse = beatsin8(6,20,100); // the pulse for fading effect using brightness (BMP,MIN_BRIGHT,MAX_BRIGHT)
- Sweeper(); //call to draw the sweep pixel
- Center(); // call to draw the center pixels, comment out for just the edge sweep
- blur2d( leds, MatrixWidth, MatrixHeight, blur);
- LEDS.setBrightness(pulse); //using the global brightness to create a fading effect, comment out if you want fully lit
- FastLED.show();
- x=x+1; // x=x+2;// use for faster speed
- }
- void Sweeper(){
- leds[sin8(7-(x))/32+(cos8(7-x)/32)*8]+= CHSV(c1,255,255); // scan pixel -clockwise circle pattern
- //leds[sin8(7-(x*2))/32+(cos8(7-x)/32)*8]+= CHSV(c1,255,255); // scan pixel -figure 8 pattern
- //leds[sin8(x)/32+(cos8(7-x)/32)*8]+= CHSV(c1,255,255); // scan pixel -anticlockwise circle pattern
- }
- void Center(){
- // the brightness of the center leds fade locally as well
- leds[27] = CHSV(c0,255,sin8(x*2));
- leds[28] = CHSV(c0,255,sin8(x*4));
- leds[35] = CHSV(c0,255,sin8(x*4));
- leds[36] = CHSV(c0,255,sin8(x*2));
- }
- //setting up to use 2d blur
- uint16_t XY( uint8_t x, uint8_t y) { return (y * MatrixWidth) + x; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement