Jaja het werkt, als hij de sketch afloopt gaat het prima, aangekomen bij de 2e ronde slaat hij vast, hij doet de leds nog wel aanzetten maar in zijn geheel slaat hij vast.
Dus eerste ronde gaat prima, bij 2e rond stop hij bij het aankomen van de VU gedeelde, nu denk ik, maar misschien zie jij dat anders, er word in deze skecht ook gewerkt met Millis, dan zou opzich geen probleem moet geven denk ik, maar als hij voor de 2 ronde langs het VU gedeelde komt, zou het dan kunnen zijn dat daar iets niet goed gaat?
daar staat oa: if (millis() - lastRefreshTime2 >= removeLedsTimeConstant) {
tot nu toe
// gaat hier om type leonardo arduino
#define FASTLED_INTERNAL // just used to mute the Pragma messages when compiling
#include "FastLED.h"
const int ledPin4 = 4;// pin nummer voor breakdance leds1
const int ledPin5 = 5;// pin nummer voor breakdance leds2
int ledState4 = LOW;
int ledState5 = LOW;
unsigned long previousMillis = 0;
const long interval = 1500;
#define PIN_STRIP1 6 //dit is strip 1 op de diamant
#define PIN_STRIP2 7 //dit is strip 2 op de diamant
#define PIN_STRIP3 8 //dit zijn de leds onder de kop
#define PIN_STRIP4 9 //dit zijn de leds op de kop
#define LED_COUNT1 26 //aantal leds op de diamant in strip 1
#define LED_COUNT2 26 //aantal leds op de diamant in strip 2
#define LED_COUNT3 10 //aantal leds onder de kop
#define LED_COUNT4 31 //aantal leds op de kop
#define LED_TYPE WS2812
#define NUM_LEDS 29
#define LED_PIN_LEFT 6
#define LED_PIN_RIGHT 7
CRGBArray<LED_COUNT1> ledsLeft;
CRGBArray<LED_COUNT2> ledsRight;
#define NUM_LEDS_RED 8
int leftChannel = 1; //analog pin
int rightChannel = 2; //analog pin
int volume = 140; //0 to 1023 - high value = lower volume
int addLedsConstant = 6 ; //how fast are LEDS added to bar
int removeLedsTimeConstant = 15; //how fast are LEDS removed from bar
int middleColorLED = 200;
int combineChannels = true; //if true channels are combined and input is only LEFT channel
int numLedsToLightLeft;
int numLedsToLightRight;
long lastRefreshTime1;
long lastRefreshTime2;
CRGBPalette16 firePalette = HeatColors_p;
CRGB leds_strip1[LED_COUNT1];
CRGB leds_strip2[LED_COUNT2];
CRGB leds_strip3[LED_COUNT3];
CRGB leds_strip4[LED_COUNT4];
unsigned long currentMillis = 0;
unsigned long startMillis = 0;
void setup() {
FastLED.addLeds<LED_TYPE, PIN_STRIP1, GRB>(leds_strip1, LED_COUNT1).setCorrection(TypicalLEDStrip);
FastLED.addLeds<LED_TYPE, PIN_STRIP2, GRB>(leds_strip2, LED_COUNT2).setCorrection(TypicalLEDStrip);
FastLED.addLeds<LED_TYPE, PIN_STRIP3, RGB>(leds_strip3, LED_COUNT3).setCorrection(TypicalLEDStrip);
FastLED.addLeds<LED_TYPE, PIN_STRIP4, RGB>(leds_strip4, LED_COUNT4).setCorrection(TypicalLEDStrip);
FastLED.clear(true); // clear alle LEDs
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
}
void purpleBlackGreen() {
uint16_t sinBeat = beatsin16(20, 0, LED_COUNT1 - 1, 0, 0);
uint16_t sinBeat2 = beatsin16(20, 0, LED_COUNT1 - 1, 0, 21845);
uint16_t sinBeat3 = beatsin16(20, 0, LED_COUNT1 - 1, 0, 43690);
leds_strip1[sinBeat] = CRGB::Purple;
leds_strip1[sinBeat2] = CRGB::Black;
leds_strip1[sinBeat3] = CRGB::Green;
fadeToBlackBy(leds_strip1, LED_COUNT1, 12);
}
void purpleBlackGreen1() {
uint16_t sinBeat = beatsin16(20, 0, LED_COUNT2 - 0, 0, 0);
uint16_t sinBeat2 = beatsin16(20, 0, LED_COUNT2 - 1, 0, 21845);
uint16_t sinBeat3 = beatsin16(20, 0, LED_COUNT2 - 1, 0, 43690);
leds_strip2[sinBeat] = CRGB::Purple;
leds_strip2[sinBeat2] = CRGB::Black;
leds_strip2[sinBeat3] = CRGB::Green;
fadeToBlackBy(leds_strip2, LED_COUNT2, 12);
}
void Sparkle(CRGB ledstrip[], int ledcount, byte red, byte green, byte blue, int SpeedDelay) {
int Pixel = random(ledcount);
ledstrip[Pixel] = CRGB(red, green, blue);
FastLED.show();
delay(70);
ledstrip[Pixel] = CRGB(0, 0, 0);
}
void juggle() {
// eight colored dots, weaving in and out of sync with each other
fadeToBlackBy( leds_strip4, LED_COUNT4, 20);
byte dothue = 0;
for ( int i = 0; i < 8; i++) {
leds_strip4[beatsin16( i + 7, 0, LED_COUNT4 - 1 )] |= CHSV(dothue, 200, 255);
dothue += 32;
}
}
void juggle1() {
// eight colored dots, weaving in and out of sync with each other
fadeToBlackBy( leds_strip1, LED_COUNT1, 20);
byte dothue = 0;
for ( int i = 0; i < 10; i++) {
leds_strip1[beatsin16( i + 7, 0, LED_COUNT1 - 1 )] |= CHSV(dothue, 200, 255);
dothue += 32;
}
}
void juggle2() {
// eight colored dots, weaving in and out of sync with each other
fadeToBlackBy( leds_strip2, LED_COUNT2, 22);
byte dothue = 0;
for ( int i = 0; i < 5; i++) {
leds_strip2[beatsin16( i + 7, 0, LED_COUNT2 - 1 )] |= CHSV(dothue, 200, 255);
dothue += 32;
}
}
#define FRAMES_PER_SECOND 30
bool gReverseDirection = false;
#define COOLING 55
#define SPARKING 120
void Fire2012()
{
// Array of temperature readings at each simulation cell
static byte heat[LED_COUNT1];
// Step 1. Cool down every cell a little
for ( int i = 0; i < LED_COUNT1; i++) {
heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / LED_COUNT1) + 2));
}
// Step 2. Heat from each cell drifts 'up' and diffuses a little
for ( int k = LED_COUNT1 - 1; k >= 2; k--) {
heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
}
// Step 3. Randomly ignite new 'sparks' of heat near the bottom
if ( random8() < SPARKING ) {
int y = random8(7);
heat[y] = qadd8( heat[y], random8(160, 255) );
}
// Step 4. Map from heat cells to LED colors
for ( int j = 0; j < LED_COUNT1; j++) {
CRGB color = HeatColor( heat[j]);
int pixelnumber;
if ( gReverseDirection ) {
pixelnumber = (LED_COUNT1 - 1) - j;
} else {
pixelnumber = j;
}
leds_strip1[pixelnumber] = color;
}
}
void Fire2013()
{
// Array of temperature readings at each simulation cell
static byte heat[LED_COUNT2];
// Step 1. Cool down every cell a little
for ( int i = 0; i < LED_COUNT2; i++) {
heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / LED_COUNT2) + 2));
}
// Step 2. Heat from each cell drifts 'up' and diffuses a little
for ( int k = LED_COUNT2 - 1; k >= 2; k--) {
heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
}
// Step 3. Randomly ignite new 'sparks' of heat near the bottom
if ( random8() < SPARKING ) {
int y = random8(7);
heat[y] = qadd8( heat[y], random8(160, 255) );
}
// Step 4. Map from heat cells to LED colors
for ( int j = 0; j < LED_COUNT2; j++) {
CRGB color = HeatColor( heat[j]);
int pixelnumber;
if ( gReverseDirection ) {
pixelnumber = (LED_COUNT2 - 1) - j;
} else {
pixelnumber = j;
}
leds_strip2[pixelnumber] = color;
}
}
void redWhiteBlue1() {
uint16_t sinBeat = beatsin16(30, 0, LED_COUNT1 - 1, 0, 0);
uint16_t sinBeat2 = beatsin16(30, 0, LED_COUNT1 - 1, 0, 21845);
uint16_t sinBeat3 = beatsin16(30, 0, LED_COUNT1 - 1, 0, 43690);
leds_strip1[sinBeat] = CRGB::Blue;
leds_strip1[sinBeat2] = CRGB::Red;
leds_strip1[sinBeat3] = CRGB::White;
fadeToBlackBy(leds_strip1, LED_COUNT1, 5);
}
void redWhiteBlue2() {
uint16_t sinBeat = beatsin16(20, 0, LED_COUNT2 - 1, 0, 0);
uint16_t sinBeat2 = beatsin16(20, 0, LED_COUNT2 - 1, 0, 21845);
uint16_t sinBeat3 = beatsin16(20, 0, LED_COUNT2 - 1, 0, 43690);
leds_strip2[sinBeat] = CRGB::Blue;
leds_strip2[sinBeat2] = CRGB::Red;
leds_strip2[sinBeat3] = CRGB::White;
fadeToBlackBy(leds_strip2, LED_COUNT2, 5);
}
void loop()
{
currentMillis = millis(); // haal de tijd op
unsigned long SinceStartTime = currentMillis - startMillis;
if (SinceStartTime < 10000)
{
Sparkle(leds_strip1, LED_COUNT1, 0xff, 0xff, 0xff, 180);
Sparkle(leds_strip2, LED_COUNT2, 0xff, 0xff, 0xff, 0);
Sparkle(leds_strip3, LED_COUNT3, 0xff, 0xff, 0xff, 0);
Sparkle(leds_strip4, LED_COUNT4, 0xff, 0xff, 0xff, 0);
FastLED.setBrightness(250);
FastLED.show();
}
else if (SinceStartTime < 20000)
{
Fire2012();
Fire2013();
fill_solid( leds_strip3, LED_COUNT3, CRGB(202, 0, 93)); //Let op NEO_GRB
fill_solid( leds_strip4, LED_COUNT4, CRGB(255, 112, 0)); //Let op NEO_GRB
FastLED.setBrightness(105);
FastLED.show();
FastLED.delay(2000 / FRAMES_PER_SECOND);
}
else if (SinceStartTime < 30000)
{
purpleBlackGreen();
purpleBlackGreen1();
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= 1500) {
previousMillis = currentMillis;
if (ledState4 == LOW) {
ledState4 = HIGH;
fill_solid( leds_strip3, LED_COUNT3, CRGB (0, 255, 0));
} else {
ledState4 = LOW;
fill_solid( leds_strip3, LED_COUNT3, CRGB(255, 0, 255));
}
digitalWrite(ledPin4, ledState4);
}
if (ledState4 == LOW) {
digitalWrite (ledPin5, HIGH);
fill_solid( leds_strip3, LED_COUNT3, CRGB(0, 255, 0));
fill_solid( leds_strip4, LED_COUNT4, CRGB(255, 0, 255));
} else {
digitalWrite (ledPin5, LOW);
fill_solid( leds_strip3, LED_COUNT3, CRGB(255, 0, 255));
fill_solid( leds_strip4, LED_COUNT4, CRGB(0, 255, 0));
}
FastLED.setBrightness(100);
FastLED.show();
}
else if (SinceStartTime < 40000)
{
digitalWrite (ledPin4, LOW);
digitalWrite (ledPin5, LOW);
juggle();
juggle1();
juggle2();
fill_solid( leds_strip3, LED_COUNT3, CRGB(0, 0, 0));
FastLED.setBrightness(150);
FastLED.show();
}
else if (SinceStartTime < 50000)
{
redWhiteBlue1();
redWhiteBlue2();
FastLED.setBrightness(100);
FastLED.show();
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= 1000) {
previousMillis = currentMillis;
if (ledState4 == LOW) {
ledState4 = HIGH;
fill_solid( leds_strip3, LED_COUNT3, CRGB(255, 0, 0));
} else {
ledState4 = LOW;
fill_solid( leds_strip3, LED_COUNT3, CRGB(0, 0, 255));
}
digitalWrite(ledPin4, ledState4);
}
if (ledState4 == LOW) {
digitalWrite (ledPin5, HIGH);
fill_solid( leds_strip3, LED_COUNT3, CRGB(255, 0, 0));
fill_solid( leds_strip4, LED_COUNT4, CRGB(0, 0, 255));
} else {
digitalWrite (ledPin5, LOW);
fill_solid( leds_strip3, LED_COUNT3, CRGB(0, 0, 255));
fill_solid( leds_strip4, LED_COUNT4, CRGB(255, 0, 0));
}
}
else if (SinceStartTime < 53000)
{
digitalWrite (ledPin4, LOW);
digitalWrite (ledPin5, LOW);
fill_solid( leds_strip1, LED_COUNT1, CRGB(255, 0, 0)); //Let op NEO_GRB
fill_solid( leds_strip2, LED_COUNT2, CRGB(255, 0, 0)); //Let op NEO_GRB
fill_solid( leds_strip3, LED_COUNT3, CRGB(255, 0, 0)); //Let op NEO_GRB
fill_solid( leds_strip4, LED_COUNT4, CRGB(255, 0, 0)); //Let op NEO_GRB
FastLED.setBrightness(100);
FastLED.show();
}
else if (SinceStartTime < 56000)
{
fill_solid( leds_strip1, LED_COUNT1, CRGB(0, 0, 255)); //Let op NEO_GRB
fill_solid( leds_strip2, LED_COUNT2, CRGB(0, 0, 255)); //Let op NEO_GRB
fill_solid( leds_strip3, LED_COUNT3, CRGB(0, 0, 255)); //Let op NEO_GRB
fill_solid( leds_strip4, LED_COUNT4, CRGB(0, 0, 255)); //Let op NEO_GRB
FastLED.setBrightness(100);
FastLED.show();
}
else if (SinceStartTime < 59000)
{
fill_solid( leds_strip1, LED_COUNT1, CRGB(0, 255, 0)); //Let op NEO_GRB
fill_solid( leds_strip2, LED_COUNT2, CRGB(0, 255, 0)); //Let op NEO_GRB
fill_solid( leds_strip3, LED_COUNT3, CRGB(0, 255, 0)); //Let op NEO_GRB
fill_solid( leds_strip4, LED_COUNT4, CRGB(0, 255, 0)); //Let op NEO_GRB
FastLED.setBrightness(100);
FastLED.show();
}
else if (SinceStartTime < 62000)
{
fill_solid( leds_strip1, LED_COUNT1, CRGB(255, 255, 0)); //Let op NEO_GRB
fill_solid( leds_strip2, LED_COUNT2, CRGB(255, 255, 0)); //Let op NEO_GRB
fill_solid( leds_strip3, LED_COUNT3, CRGB(255, 255, 0)); //Let op NEO_GRB
fill_solid( leds_strip4, LED_COUNT4, CRGB(255, 255, 0)); //Let op NEO_GRB
FastLED.setBrightness(100);
FastLED.show();
}
else if (SinceStartTime < 65000)
{
fill_solid( leds_strip1, LED_COUNT1, CRGB(0, 255, 255)); //Let op NEO_GRB
fill_solid( leds_strip2, LED_COUNT2, CRGB(0, 255, 255)); //Let op NEO_GRB
fill_solid( leds_strip3, LED_COUNT3, CRGB(0, 255, 255)); //Let op NEO_GRB
fill_solid( leds_strip4, LED_COUNT4, CRGB(0, 255, 255)); //Let op NEO_GRB
FastLED.setBrightness(100);
FastLED.show();
}
else if (SinceStartTime < 68000)
{
fill_solid( leds_strip1, LED_COUNT1, CRGB(255, 0, 255)); //Let op NEO_GRB
fill_solid( leds_strip2, LED_COUNT2, CRGB(255, 0, 255)); //Let op NEO_GRB
fill_solid( leds_strip3, LED_COUNT3, CRGB(255, 0, 255)); //Let op NEO_GRB
fill_solid( leds_strip4, LED_COUNT4, CRGB(255, 0, 255)); //Let op NEO_GRB
FastLED.setBrightness(100);
FastLED.show();
}
else if (SinceStartTime < 71000)
{
fill_solid( leds_strip1, LED_COUNT1, CRGB(0, 0, 255)); //Let op NEO_GRB
fill_solid( leds_strip2, LED_COUNT2, CRGB(0, 0, 255)); //Let op NEO_GRB
fill_solid( leds_strip3, LED_COUNT3, CRGB(255, 255, 255)); //Let op NEO_GRB
fill_solid( leds_strip4, LED_COUNT4, CRGB(255, 0, 0)); //Let op NEO_GRB
FastLED.setBrightness(100);
FastLED.show();
}
else if (SinceStartTime < 80000)
{
int ledsToLightLeft = map(analogRead(leftChannel), 0, volume, 0, LED_COUNT1);
int ledsToLightRight = map(analogRead(rightChannel), 0, volume, 0, LED_COUNT2);
if (combineChannels) {
ledsToLightRight = ledsToLightLeft;
}
if (ledsToLightLeft > numLedsToLightLeft) {
numLedsToLightLeft += 3;
} else if (ledsToLightLeft < numLedsToLightLeft) {
if (millis() - lastRefreshTime1 >= 80) {
lastRefreshTime1 += 80;
numLedsToLightLeft -= 1;
}
}
if (numLedsToLightLeft < 1) {
numLedsToLightLeft = 0;
}
if (numLedsToLightLeft > LED_COUNT1) {
numLedsToLightLeft = LED_COUNT1;
}
if (ledsToLightRight > numLedsToLightRight) {
numLedsToLightRight += addLedsConstant;
} else if (ledsToLightRight < numLedsToLightRight) {
if (millis() - lastRefreshTime2 >= removeLedsTimeConstant) {
lastRefreshTime2 += removeLedsTimeConstant;
numLedsToLightRight -= 1;
}
}
if (numLedsToLightRight < 1) {
numLedsToLightRight = 0;
}
if (numLedsToLightRight > LED_COUNT2) {
numLedsToLightRight = LED_COUNT2;
}
for (int led = 0; led < numLedsToLightLeft; led++) {
if (led < middleColorLED) {
leds_strip1[led] = CRGB(map(led, 0, middleColorLED - 25, 0, 255) , 255, 0);
} else {
leds_strip1[led] = CRGB(255, map(led, middleColorLED, LED_COUNT1, 255, 0), 0);
}
}
for (int led = LED_COUNT1; led >= numLedsToLightLeft; led--) {
leds_strip1[led] = CRGB(0, 0, 0);
}
for (int led = 0; led < numLedsToLightRight; led++) {
if (led < middleColorLED) {
leds_strip2[led] = CRGB(map(led, 0, middleColorLED - 25, 0, 255) , 255, 0);
} else {
leds_strip2[led] = CRGB(255, map(led, middleColorLED, LED_COUNT2, 255, 0), 0);
}
}
for (int led = LED_COUNT2; led >= numLedsToLightRight; led--) {
leds_strip2[led] = CRGB(0, 0, 0);
}
for (int i = LED_COUNT2 - NUM_LEDS_RED; i <= LED_COUNT2; i++) {
if (leds_strip2[i] != CRGB(0, 0, 0)) {
leds_strip2[i] = CRGB::Red;
}
if (leds_strip1[i] != CRGB(0, 0, 0)) {
leds_strip1[i] = CRGB::Red;
}
}
FastLED.show();
}
else if (SinceStartTime < 95000)
{
fill_solid( leds_strip1, LED_COUNT1, CRGB(0, 0, 0)); //Let op NEO_GRB
fill_solid( leds_strip2, LED_COUNT2, CRGB(0, 0, 0)); //Let op NEO_GRB
fill_solid( leds_strip3, LED_COUNT3, CRGB(0, 0, 0)); //Let op NEO_GRB
fill_solid( leds_strip4, LED_COUNT4, CRGB(0, 0, 0)); //Let op NEO_GRB
FastLED.show();
startMillis = millis(); //start opnieuw door de start tijd op nu te zetten
}
}