5 Volts reaction in code

Hello everyone! I have a question. I have code for LED stripes and I want to make i trick with power. When I turn On power (5 Volts) I want to see working first array, when i turn another 5 Volts I want to see another array.

How is possible in this code?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <FastLED.h>
#define NUM_LEDS_PER_STRIP 18
#define CLOCK_PIN 2
CRGB leftLeds[NUM_LEDS_PER_STRIP];
CRGB rightLeds[NUM_LEDS_PER_STRIP];

void setup() {
  FastLED.addLeds<LPD8806, CLOCK_PIN, 3>(leftLeds, NUM_LEDS_PER_STRIP);
  FastLED.addLeds<LPD8806, CLOCK_PIN, 5>(rightLeds, NUM_LEDS_PER_STRIP);
}

 void loop() {
        for(int dot = 0; dot < NUM_LEDS_PER_STRIP; dot++) { 
            leftLeds[dot] = CRGB::Blue;
            rightLeds[dot] = CRGB::Blue;
            FastLED.show();
            // clear this led for the next time around the loop
            leftLeds[dot] = CRGB::Red;
            rightLeds[dot] = CRGB::Red;
            delay(100);
        }
    }


I'M USING ARDUINO!
Last edited on
I don't completely understand the setup...

you have 2 voltages, right?
Is it like this:
- if you turn 1 of them on you want to have the leftLeds if you turn both on you want to have the rightLeds?
Table:
 v1 | v2 || or | ol
  0 |  0 || 0  | 0
  0 |  1 || 0  | 1
  1 |  0 || 0  | 1
  1 |  1 || 1  | 0

or ... output right
ol ... output left
v1 ... voltage 1 (digital value)
v2 ... voltage 2 (digital value)

or like this:
- if you turn the left on you want to turn on the leftLeds and if you turn the right on you want to have the rightLeds?
Table:
 v1 | v2 || or | ol
  0 |  0 || 0  | 0
  0 |  1 || 0  | 1
  1 |  0 || 1  | 0
  1 |  1 || 1  | 1
Last edited on
Sorry for bad explanation. I ll describe everithing clearly.

I have two led stripe. On the left and right sides. My goal is to control both of them with two buttons. On each button current 5 Volts. When button one is ON, I need left stripe ON. When second button ON, i need right stripe ON. When both buttons are off, I need two stripes working with one function.

I was thinking how to make it correctly and i have an idea. When button for left stripe is ON, i need one of the pins on ATmega (arduino) recognize, that power is ON. And etc...

I dont know how to write is in the code. If you know how to do this or yuo can make it with explanation, please, help. Basicly its a project and If you are intrested, text me email: ivalik.sc@gmail.com I ll pay for help. Thank you!
I ll pay for help.
I lost interest on that line, thanks

When button one is ON, I need left stripe ON. When second button ON, i need right stripe ON. When both buttons are off, I need two stripes working with one function.
That's all you need to know, just check the digital input of both buttons and then do it accordingly
Topic archived. No new replies allowed.