For context I am very new to programming and electronics and would really appreciate if someone could help out.
Im using the neopixel library frame code with the running lights source code from https://www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/#NeoPixelFramework and getting the error message 'Compilation error: 'RunningLights' was not declared in this scope'
I'm running a WS2812 LED strip with an arduino nano and theres no hardware issues, the test code runs perfectly fine
heres the code:
#include <Adafruit_NeoPixel.h>
#define PIN 2
#define NUM_LEDS 100
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
RunningLights(0xff,0,0, 50); // red
RunningLights(0xff,0xff,0xff, 50); // white
RunningLights(0,0,0xff, 50); // blue
}
void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
FastLED.show();
#endif
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
#endif
}
void setAll(byte red, byte green, byte blue) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
showStrip();
}`Use code tags to format code for the forum`
You need to create a function called RunningLights().
There is no function called RunningLights in that code.
And your sketch is nowhere to be found on the page you linked to.
Did you possibly mean something from:
sorry, ive linked to the wrong page. heres the correct link
Sorry for how stupid I'm about to sound, but how would i go about creating a function?
You will need to learn to program... so, short of teaching, here is the function from the link above.
Paste it into your code...
void RunningLights(byte red, byte green, byte blue, int WaveDelay) {
int Position=0;
for(int j=0; j<NUM_LEDS*2; j++)
{
Position++; // = 0; //Position + Rate;
for(int i=0; i<NUM_LEDS; i++) {
// sine wave, 3 offset waves make a rainbow!
//float level = sin(i+Position) * 127 + 128;
//setPixel(i,level,0,0);
//float level = sin(i+Position) * 127 + 128;
setPixel(i,((sin(i+Position) * 127 + 128)/255)*red,
((sin(i+Position) * 127 + 128)/255)*green,
((sin(i+Position) * 127 + 128)/255)*blue);
}
showStrip();
delay(WaveDelay);
}
}
Thank you so much for your help and your patience, that has done the trick :)
Good.
Please flag the thread as "Solved" (by marking the post #8 as the solution).
