Hello, I am having some difficulty with some code.

Hello,

I am having some difficulty with some code. I am using the DemoReel100 example as the basis of my project. The code is running on a Circuit Playground Express and I would like to be able to use both buttons and the slide switch on the board to control the leds.

The base example code runs without issues as long as I modify the data pin and LED type. I was able to get both buttons working for changing the pattern and 'base color" but when I tried to add in the functionality of the slide switch the code fails to compile for the board.

The first link is the error message and the second link is the code, any help would be greatly appreciated and please forgive me for being such a noob with all this.

https://hastebin.com/fasobeguzo.http

https://hastebin.com/uhuxobavez.cpp

@Slater_Rubin line 105 could you add a ‘;’ at the end of the line ?
But then what do you want your code to to when the switch is low

@Yves_BAZIN Adding the semicolon after the closing bracket did not seem to fix the error of compiling for the board.

I would like the example code to run through the base color and change patterns without the need to press any buttons, basically to run like normal.

@Slater_Rubin if you don’t have this piece of code you can compile it ?

No having or not having the semicolon at the end of line 105 does not seem to make any difference

@Slater_Rubin Could you please use the latest version of the Artnet library because it seems that there is a bug in the definition of the EVERY_N_MILLIS and your are using version 3.00 and we are et 3.1.8

let me know

@Slater_Rubin I wonder the use of your ‘while’ of line 105
if you do not push any button will will be stucked in this loop
for me you can comment that line

@Slater_Rubin i have made some changes in your code
https://hastebin.com/wazuveviye.cpp

@Yves_BAZIN the link you shared goes to a blank page.

@Slater_Rubin strange I don’t see it either even by clinking on you original link. could you republish your code ?
Have you tried upgrading the fastled library ?

@Yves_BAZIN I’m at work right now when I get home I’ll repost it.

@Yves_BAZIN I tested the code you modified, and the demo works when the switch is low, everything cycles like it should.

But when the switch reads high the buttons do not function as before, they do nothing.

Your code is able to be viewed on PC but not mobile.

My FastLED library is currently on 3.002

I had an idea, instead of using the switch to control the demo, how about making the demo a pattern instead, and adding that pattern to the pattern list?

@Slater_Rubin that is possible indeed

@Yves_BAZIN Ive tried doing that, and it only seems to display the bpm pattern while cycling through the base color.

I understand that this is happening because it is the last line in that pattern so it stops on that after very quickly displaying every other one, but I cannot figure out how to get it to display each pattern for 10 seconds while cycling through the base color.

Ive tried adding delays in between each pattern in the demo pattern but as expected that resulted in very slow animations that did not look good.

Any ideas?

Here is the code I have so far.

https://pastebin.com/a0rUkmiL

@Slater_Rubin I am not used to CircuitPlayground but your code look correct but I would write
if(leftButtonPressed==HIGH)
same for the other test
try that and let me know

The buttons work cycling through each individual pattern, but when we reach the ‘demo’ pattern it only displays bpm(); which is the last line inside ‘demo’

Are you saying to add if(leftButtonPressed==HIGH) in between each pattern listed inside the ‘demo’ pattern?

@Slater_Rubin oh ok you want to have demo program cycling through each pattern by itself instead of pushing a button ?

@Slater_Rubin
try this
replace your demo function by this
int count=0;
int p=0;
void demo()
{
EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the “base color” through the rainbow
if(count<200)
{
gPatternsp;
count++;
}
else
{
count=0;
p=(p+1)%(ARRAY_SIZE( gPatterns)-1);
}
}

@Yves_BAZIN That is exactly what I was looking for, thank you very much. Ill be sure to post my project soon.