Guest User

Untitled

a guest
Apr 8th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. /*
  2. *This sketch outputs images to persistence of vision led strips
  3. *It uses FastLed to drive APA102 leds, sending colour values from
  4. *arrays held in flash memory (designated by 'const'). You need to
  5. *set the number of slices you have made your image into,
  6. *e.g. bmp image of 60 pixels high by 150 wide
  7. * would give 60 num_leds and
  8. * 150 slices (number of slices you have made your image into)
  9. */
  10.  
  11. #include "FastLED.h"
  12.  
  13. #define NUM_LEDS 60 //number of leds in strip length on one side
  14. #define DATA_PIN 2//7 = second hardware spi data
  15. #define CLOCK_PIN 3//14 = second hardware spi clock
  16. CRGB leds[NUM_LEDS];
  17. int numberOfSlices = 150;
  18.  
  19. void setup() {
  20.  
  21. delay(200);
  22. FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN>(leds, NUM_LEDS);
  23. }
  24.  
  25. const unsigned int array0[] = {0x80d06, IMAGE ARRAY GOES HERE (generated using Mortonkopf's web tool};//holly
  26. const unsigned int array0[] = {AND HERE....};//snow
  27.  
  28.  
  29. void loop() {
  30. PoiSonic(2000,array0); //call method, with duration to show (2sec) and array name.
  31. PoiSonic(2000,array1);
  32. }
  33.  
  34.  
  35. //The magic loop
  36.  
  37. void PoiSonic(unsigned long time, const unsigned int array[]){
  38. unsigned long currentTime = millis();
  39. while (millis()< currentTime + (time)) {
  40.  
  41. int f= numberOfSlices;
  42. int z; //a counter
  43. int j=NUM_LEDS;
  44.  
  45. for (int x=0;x<f;x++){
  46. for(z=NUM_LEDS;z>0;z--){
  47. leds[z-1]=array[x+((j-z)*f)];}
  48. FastLED.show();
  49. delayMicroseconds(40); //may need to increase / decrease depending on spin rate
  50. }
  51. delayMicroseconds(1000); //may need to increase / decrease depending on spin rate
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment