Hi! So I'm very green to all of this and I am following a project on making Graphic Poi (basically a light tube you swing around and it shows a bitmap. In the tutorial they post that they "key to the loop" is this code:
for (int x=0;x<f;x++){
for(z=NUM_LEDS;z>0;z--){
leds[z-1]=array[x+((j-z)*f)];}
FastLED.show();
They then post an "example code" where I filled out the array area with my own image converted through a link provided:
#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(leds, NUM_LEDS);
}
const unsigned int array1[] = { 0x000100, 0x000100, 0x000100, 0x000100, 0x000100, 0x000100, /*etc .. add your values here*/}; //end of array
void loop() {
PoiSonic(8000,array1);//holly
}
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;x0;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
}
}
I have made minor adjustments based on currently functioning examples to get it to ALMOST verify. But when I add the first chunk of code into the loop it comes up with "f" was not declared in this scope. If I leave it out it does the same thing just further down in the code? Any help of what to do here or where to declare what?
Error Messages:
Arduino: 1.8.12 (Windows 10), TD: 1.52, Board: "Teensy 3.5, Serial, 120 MHz, Faster, US English"
In file included from C:\Users\snore\AppData\Local\Temp\arduino_modified_sketch_234499\strandtest.ino:11:0:
C:\Users\snore\Documents\Arduino\libraries\FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.003.003
# pragma message "FastLED version 3.003.003"
^
strandtest: In function 'void loop()':
strandtest:93: error: 'f' was not declared in this scope
for (int x=0;x<f;x++){
^
strandtest:94: error: 'z' was not declared in this scope
for(z=NUM_LEDS;z>0;z--){
^
strandtest:95: error: 'array' was not declared in this scope
leds[z-1]=array[x+((j-z)*f)];}
^
strandtest:95: error: 'j' was not declared in this scope
leds[z-1]=array[x+((j-z)*f)];}
^
strandtest:98: error: 'PoiSonic' was not declared in this scope
PoiSonic(8000,array1);//holly
^
strandtest:101: error: a function-definition is not allowed here before '{' token
void PoiSonic(unsigned long time, const unsigned int array[]){
^
strandtest:110: error: expected '}' at end of input
}
^
Multiple libraries were found for "FastLED.h"
Used: C:\Users\snore\Documents\Arduino\libraries\FastLED
Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED
'f' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
EDIT: My bad, here's the actual slightly modified code I ran. I have chopped down the actual array data to fit in this forum. I assure you it is just a long series of 0x00000 type data.
/*
*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 6//7 = second hardware spi data
#define CLOCK_PIN 3//14 = second hardware spi clock
CRGB leds[NUM_LEDS];
int numberOfSlices = 100;
void setup() {
delay(200);
FastLED.addLeds<WS2812, DATA_PIN> (leds, NUM_LEDS);
}
const unsigned int array1[] = { 0x000000, 0x000000, 0x000000 }; //end of array THIS WAS THE MASSIVE WALL OF TEXT EDITED OUT. IF YOU NEED THE FULL BLOCK FOR SOME REASON LET ME KNOW
void loop() {
for (int x=0;x<f;x++){
for(z=NUM_LEDS;z>0;z--){
leds[z-1]=array[x+((j-z)*f)];}
FastLED.show();
PoiSonic(8000,array1);//holly
}
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;x0;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
}
}
Website to project I'm following: http://orchardelica.com/wp/?page_id=597