Advertisement
sprocket2cog

Radar Scope 1.1 fastled arduino

Nov 8th, 2015
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.87 KB | None | 0 0
  1. //----------------------------------------------------
  2. // sprocket2cog 2015 cc
  3. // Radar scope animation code 1.1
  4. // thanks to the arduino and fastled community
  5. //----------------------------------------------------
  6.  
  7. #include "FastLED.h"
  8. #define DATA_PIN    6
  9. #define CHIPSET     WS2812B
  10. #define COLOR_ORDER GRB
  11. #define NUM_LEDS    64
  12. #define BRIGHTNESS  255
  13. CRGB leds[NUM_LEDS];
  14. const uint8_t MatrixWidth  = 8;
  15. const uint8_t MatrixHeight = 8;
  16. int x=0;
  17. int c0 = 96; //hue value for centre of radar
  18. int c1 = 0;  //hue value for the radar sweep
  19.  
  20. void setup() {
  21.   FastLED.addLeds<CHIPSET, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  22.   LEDS.setBrightness(BRIGHTNESS);
  23. }
  24.  
  25. void loop() {
  26.   uint8_t blur = beatsin8(60,30,60); // the variable for the 2d blur effect
  27.   int pulse = beatsin8(6,20,100); // the pulse for fading effect using brightness (BMP,MIN_BRIGHT,MAX_BRIGHT)
  28.   Sweeper(); //call to draw the sweep pixel
  29.   Center();  // call to draw the center pixels, comment out for just the edge sweep
  30.   blur2d( leds, MatrixWidth, MatrixHeight, blur);
  31.   LEDS.setBrightness(pulse); //using the global brightness to create a fading effect, comment out if you want fully lit
  32.   FastLED.show();
  33.   x=x+1; // x=x+2;// use for faster speed
  34. }
  35.  
  36. void Sweeper(){
  37.    leds[sin8(7-(x))/32+(cos8(7-x)/32)*8]+= CHSV(c1,255,255); // scan pixel -clockwise circle pattern
  38.  //leds[sin8(7-(x*2))/32+(cos8(7-x)/32)*8]+= CHSV(c1,255,255); // scan pixel -figure 8 pattern
  39.  //leds[sin8(x)/32+(cos8(7-x)/32)*8]+= CHSV(c1,255,255); // scan pixel -anticlockwise circle pattern
  40. }
  41.  
  42. void Center(){
  43.    // the brightness of the center leds fade locally as well
  44.    leds[27] = CHSV(c0,255,sin8(x*2));
  45.    leds[28] = CHSV(c0,255,sin8(x*4));
  46.    leds[35] = CHSV(c0,255,sin8(x*4));
  47.    leds[36] = CHSV(c0,255,sin8(x*2));
  48. }
  49.  
  50. //setting up to use 2d blur
  51. uint16_t XY( uint8_t x, uint8_t y) { return (y * MatrixWidth) + x; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement