Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *This sketch outputs images to persistence of vision led strips
- *It uses FastLed to drive APA102 leds, sending colour values from
- *arrays held in flash memory (designated by 'const'). You need to
- *set the number of slices you have made your image into,
- *e.g. bmp image of 60 pixels high by 150 wide
- * would give 60 num_leds and
- * 150 slices (number of slices you have made your image into)
- */
- #include "FastLED.h"
- #define NUM_LEDS 60 //number of leds in strip length on one side
- #define DATA_PIN 2//7 = second hardware spi data
- #define CLOCK_PIN 3//14 = second hardware spi clock
- CRGB leds[NUM_LEDS];
- int numberOfSlices = 150;
- void setup() {
- delay(200);
- FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN>(leds, NUM_LEDS);
- }
- const unsigned int array0[] = {0x80d06, IMAGE ARRAY GOES HERE (generated using Mortonkopf's web tool};//holly
- const unsigned int array0[] = {AND HERE....};//snow
- void loop() {
- PoiSonic(2000,array0); //call method, with duration to show (2sec) and array name.
- PoiSonic(2000,array1);
- }
- //The magic loop
- void PoiSonic(unsigned long time, const unsigned int array[]){
- unsigned long currentTime = millis();
- while (millis()< currentTime + (time)) {
- int f= numberOfSlices;
- int z; //a counter
- int j=NUM_LEDS;
- for (int x=0;x<f;x++){
- for(z=NUM_LEDS;z>0;z--){
- leds[z-1]=array[x+((j-z)*f)];}
- FastLED.show();
- delayMicroseconds(40); //may need to increase / decrease depending on spin rate
- }
- delayMicroseconds(1000); //may need to increase / decrease depending on spin rate
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment