Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I have a problema #796

Open
Firemanpl opened this issue May 18, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@Firemanpl
Copy link

commented May 18, 2019

Hello. At the beginning I would like to say that I am a beginner in arduino as well as in the FastLed.h library. I have a variable switchonoff2 which can be switched on / off on ttp223 when touched. At the beginning I had such a plan: if switchonoff2 == HIGH then scale the brightness with 255 to zero and if LOW is the opposite. I managed to do it. Later I wanted to connect under if switchonoff2 == HIGH onoff = 1; and I was writing adequately to LOW vice versa. I wrote if that would check it and in this if I put some coded code from a different project. (I did a bit). The problem is that when I turn on switchonoff2 the second bar only runs the problem in this code causes some complications and the diode refreshes as if it wanted and could not. Automatically, as I turn on the diode, the second refreshes with resistance as if with a significant delay. Even how I removed the delay (10); the problem will not disappear.a movie to illustrate it: LINK
`

#include "FastLED.h"
#define NUM_LEDS 2 // liczba led 1 paska
CRGB leds[NUM_LEDS]; //tablica 1 paska
#define PIN 7 // data ws2812b 1 paska
#define COLOR_ORDER GRB
int i = 255;
int j = 255;
int switchonnoff1 = 3; //switch włącz/wyłącz 1
int switchonnoff2 = 4; //switch włącz/wyłącz 2
//animation strio led 2
#define NUM_LEDSs 56
CRGBArray<NUM_LEDSs> ledss; //tablica 2 paska
uint8_t hue[NUM_LEDSs];
#define PINa 6 //data2 strip
int onoff = 0;
//}animation strio led 2
void setup()
{
    FastLED.addLeds<WS2812B, PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
    //animation strio led 2
    FastLED.addLeds<NEOPIXEL, PINa>(ledss, NUM_LEDSs);
    for (int i = 0; i < NUM_LEDSs; i++) {
        hue[i] = 255 / NUM_LEDSs * i;
    }
    //animation strio led 2
}

void loop()
{
    leds[1].setRGB(255, 0, 255);
    leds[1].fadeLightBy(j);
    leds[0].setRGB(255, 255, 0);
    leds[0].fadeLightBy(i);
    if (digitalRead(switchonnoff1) == LOW) {
        if (i < 255) {
            i = i + 3;
        }
    }
    if (digitalRead(switchonnoff1) == HIGH) {
        if (i > 0) {
            i = i - 3;
        }
    }
    if (digitalRead(switchonnoff2) == LOW) {
        onoff = 0;
        if (j < 255) {
            j = j + 3;
        }
    }
    if (digitalRead(switchonnoff2) == HIGH) {
        onoff = 1;
        if (j > 0) {
            j = j - 3;
        }
    }
    FastLED.show();
    //animation strio led 2
    if (onoff == 1) {
        for (int i = 0; i < NUM_LEDSs; i++) {
            ledss[i] = CHSV(hue[i]++, 255, 255);
            FastLED.show();
        }
        //}animation strio led 2
    }
}   

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.