Hello, I am having some difficulty with some code.

fastled-support
gplus
(Slater Rubin) #1

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

(Yves BAZIN) #2

@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

(Slater Rubin) #3

@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.

(Yves BAZIN) #4

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

(Slater Rubin) #5

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

(Yves BAZIN) #6

@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

(Yves BAZIN) #7

@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

(Yves BAZIN) #8

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

(Slater Rubin) #9

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

(Yves BAZIN) #10

@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 ?

(Slater Rubin) #11

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

(Slater Rubin) #12

@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

(Slater Rubin) #13

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?

(Yves BAZIN) #14

@Slater_Rubin that is possible indeed

(Slater Rubin) #15

@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

(Yves BAZIN) #16

@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

(Slater Rubin) #17

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?

(Yves BAZIN) #18

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

(Yves BAZIN) #19

@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);
}
}

(Slater Rubin) #20

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