Moved to the forum, from this comment.
Original question:
Hey it’s me again
I’m struggling once again with my LED-Matrix….
I’ve made big changes to my source code…
1. I’m using different switches now
2. I’m having an active low circuit
3. I kicked out some projects
Now I’m running in a new problem…
My project wasn’t working so I started with a program which was (it was the funmode)
The program uses the Neopixel Library.
I got everything to work and I wanted to slowly add the other programs.
With the Twinklerandom from this page I started to struggle…. (It’s the “Random Color Twinkle” Programm from this page)
The Twinklerandom was working well but the other wasn’t…
I found out that it was cuz one variable was too big…
It’s the NUM_LED’s variable that I use in the Twinklerandom function.
Now I’m having the problem that I can only run this program with 193 LED’s and not with the 340 that I have in my LED strip.
Am I missing an important point?
This isn’t my full code I was focussing on 2 Programs and add another one when these r working fine. And continue with that till I have all my projects in the programm.
Code:
//includes
#include <Adafruit_NeoPixel.h> //Funmode
#include "FastLED.h" //Aufblinken
//defines
#define PIN 6
#define DATA_PIN 6
#define NUM_LEDS 193
//Funktion-Initialisierung
void funmode();
//void TwinkleRandom(int, int, int, boolean);
//Eingangspins
int aufblinkeneinput = 11;
int funmodeinput = 9;
//andere
CRGB leds[NUM_LEDS];
Adafruit_NeoPixel strip = Adafruit_NeoPixel(340, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show();
Serial.begin(9600);
LEDS.addLeds<NEOPIXEL,DATA_PIN>(leds,NUM_LEDS);
//Eingangspins als INPUT definieren
pinMode(aufblinkeneinput, INPUT);
pinMode(funmodeinput, INPUT);
}
void loop() {
if(digitalRead(aufblinkeneinput) == LOW) {
TwinkleRandom(1800,100,150,false);
}
if(digitalRead(funmodeinput) == LOW) {
funmode();
}
}
//Hauptfunktion im Loop
//1. Aufblinken
void TwinkleRandom(int Count, int SpeedDelay, int fadespeed, boolean OnlyOne) {
setAll(0,0,0);
for (int i=0; i<Count; i++) {
fadeall(fadespeed);
setPixel(random(NUM_LEDS),random(0,255),random(0,192),random(0,128));
showStrip();
delay(SpeedDelay);
if(OnlyOne) {
setAll(0,0,0);
}
}
// delay(SpeedDelay);
}
//3. Funmode
void funmode() {
// Some example procedures showing how to display to the pixels:
colorWipe(strip.Color(255, 0, 0), 50); // Red
colorWipe(strip.Color(0, 255, 0), 50); // Green
colorWipe(strip.Color(0, 0, 255), 50); // Blue
// Send a theater pixel chase in...
theaterChase(strip.Color(127, 127, 127), 50); // White
theaterChase(strip.Color(127, 0, 0), 50); // Red
theaterChase(strip.Color( 0, 0, 127), 50); // Blue
rainbow(20);
rainbowCycle(20);
theaterChaseRainbow(50);
}
//Deklaration der Hauptfunktionen
//1. Aufblinken
void setPixel(int Pixel, byte red, byte green, byte blue) {
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
}
void setAll(byte red, byte green, byte blue) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
showStrip();
}
void showStrip() {
FastLED.show();
}
void fadeall(int scale) { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(scale); } }
//3. Funmode
// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
void rainbow(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256; j++) {
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i+j) & 255));
}
strip.show();
delay(wait);
}
}
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}
//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
for (int j=0; j<10; j++) { //do 10 cycles of chasing
for (int q=0; q < 3; q++) {
for (int i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, c); //turn every third pixel on
}
strip.show();
delay(wait);
for (int i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, 0); //turn every third pixel off
}
}
}
}
//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
for (int j=0; j < 256; j++) { // cycle all 256 colors in the wheel
for (int q=0; q < 3; q++) {
for (int i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, Wheel( (i+j) % 255)); //turn every third pixel on
}
strip.show();
delay(wait);
for (int i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, 0); //turn every third pixel off
}
}
}
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
if(WheelPos < 85) {
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
} else if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}