Thanks for the add...My 1st post here
I am using an Ardunio Uno and FastLED library for my 1st project.
I have the LED strips (WS2812B) working like I like but I then wanted to use my UNO with two inputs to drive two outputs.
I cut'n pasted my working code into the IF/ELSE statement and it doesn't work as it did outside the IF statements.
It basically is acting like may INPUT value is HIGH even when I physically remove the INPUT wire from the UNO
Any thoughts... Here is my code. The LED strips are just blinking and scrolling in some pattern. My goal is to have a structure where I can/add the code and have the IF/ELSE function.
#include <FastLED.h>
#define LED_PIN 5
//#define CLOCK_PIN 4
#define NUM_LEDS 7 //Edit this to equal the number of LEDs connected to each code for the light system
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define BRIGHTNESS 64 //Default unless overridden in the line of code. This isn't used in my current version
int LeftSWITCH = 8; //Pin number wire is connected to
int LeftLED = 5; //Pin number wire is connected to
//int RightSWITCH = 13; //Pin number wire is connected to
//int RightLED = 12; //Pin number wire is connected to
CRGB leds[NUM_LEDS];
void setup() {
// put your setup code here, to run once:
delay(1000);
LEDS.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);
// LEDS.addLeds<LED_TYPE, LED_PIN, CLOCK_PIN COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
pinMode(LeftSWITCH, INPUT); // 5v + from 12v/5v transformer
//pinMode(RightSWITCH, INPUT); // 5v + from 12v/5v transformer
pinMode(LeftLED, OUTPUT); // Data out to strip
//pinMode(RightLED, OUTPUT); // Data out to strip
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(LeftSWITCH)== HIGH) {
//digitalWrite(LeftLED, HIGH);
for(int i=0;i<NUM_LEDS;i++){
leds*.setRGB(255,0,0);*
- FastLED.setBrightness(150);*
- FastLED.show();*
- delay(90); //Lower number is faster blinking*
- FastLED.clear();*
} - }*
else{
// digitalWrite(LeftLED, LOW); - for(int i=0;i<NUM_LEDS;i++){*
_ leds*.setRGB(0,0,0);_
_ FastLED.show();_
_ }_
_}_
_}*_