I have connected my stripLED connected to a pin set as an output and I would like to control it with 3 or more pin inputs and I couldn't. Help me

#include "Arduino.h"
#include <FastLED.h>

#define LED_PIN 6 //LED Strip Signal Connection
#define SignalA 3
#define SignalB 4
#define SignalC 5
#define NUM_LEDS 120 //Total no of LEDs in the LED strip
#define BRIGHTNESS 50

int BlinkerSpeed1 = 20; //Turn Signal Running LED Speed
int BlinkerSpeed2 = 500;
CRGB leds[NUM_LEDS];

void setup() {
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
pinMode(SignalA, INPUT);
pinMode(SignalB, INPUT);
pinMode(SignalC, INPUT);
pinMode(LED_PIN, OUTPUT);
}

void loop() {

if((digitalRead(SignalA)==0)&&(digitalRead(SignalB)==0)&&(digitalRead(SignalC)==0))
{
fullgreen();
}

if((digitalRead(SignalA)==1)&&(digitalRead(SignalB)==0)&&(digitalRead(SignalC)==1))
{
fullred();
}

if((digitalRead(SignalA)==0)&&(digitalRead(SignalB)==1)&&(digitalRead(SignalC)==0))
{
fullyellow();
}

if((digitalRead(SignalA)==0)&&(digitalRead(SignalB)==1)&&(digitalRead(SignalC)==1))
{
fullblue();
}

if((digitalRead(SignalA)==1)&&(digitalRead(SignalB)==0)&&(digitalRead(SignalC)==0))
{
fullwhite();
}

if((digitalRead(SignalA)==1)&&(digitalRead(SignalB)==0)&&(digitalRead(SignalC)==1))
{
frontwhiteandbackred();
}

if((digitalRead(SignalA)==1)&&(digitalRead(SignalB)==1)&&(digitalRead(SignalC)==0))
{
yellowrightturn();
}

if((digitalRead(SignalA)==1)&&(digitalRead(SignalB)==1)&&(digitalRead(SignalC)==1))
{
yellowleftturn();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void fullgreen()
{
for (int i = 0; i < 120; i++)/////////////FullGreen////////
{
leds[i] = CRGB(0, 255, 0);
}
FastLED.show();
}

void fullred()
{
for (int i = 0; i < 120; i++)/////////////FullRed//////////////
{
leds[i] = CRGB(255, 0, 0);
}
FastLED.show();
}

void fullwhite()
{
for (int i = 0; i < 120; i++)/////////////FullWhite//////////
{
leds[i] = CRGB(255, 255, 255);
}
FastLED.show();
}

void fullblue()
{
for (int i = 0; i < 120; i++)/////////////FullBlue//////////
{
leds[i] = CRGB(0, 0, 255);
}
FastLED.show();
}

void fullyellow()
{
for (int i = 0; i < 120; i++)/////////////FullYellow///////////////////
{
leds[i] = CRGB(255, 255, 0);
}
FastLED.show();
delay (BlinkerSpeed2);
for (int i = 0; i < 120; i++)
{
leds[i] = CRGB(0, 0, 0);
}
FastLED.show();
delay (BlinkerSpeed2);
}

void frontwhiteandbackred()
{
for (int i = 0; i < 60; i++)/////////////White-Front//////////
{
leds[i] = CRGB(255, 255, 255);
}
for (int i = 60; i < 120; i++)/////////////Red-Back///////////
{
leds[i] = CRGB(255, 0, 0);
}
FastLED.show();
}

void yellowleftturn()
{
for (int i = 0; i < 40; i++)/////////////White-Front//////////////
{
leds[i] = CRGB(255, 255, 255);
}
for (int i = 80; i < 120; i++)/////////////Red-Back///////////////
{
leds[i] = CRGB(255, 0, 0);
}
for (int j = 40; j< 60; j++)////////////YellowLeftturn///////////
{
leds[j] = CRGB(255, 255, 0);
leds[(NUM_LEDS/2-1)+((NUM_LEDS/2)-j)] = CRGB(255, 255, 0);
FastLED.show();
delay (BlinkerSpeed1);
}
for (int j = 40; j< 60; j++)
{
leds[j] = CRGB(0, 0, 0);
leds[(NUM_LEDS/2-1)+((NUM_LEDS/2)-j)] = CRGB(0, 0, 0);
delay (BlinkerSpeed1);
}
}

void yellowrightturn()
{
for (int i = 20; i < 60; i++)/////////////White-Front///////////////////
{
leds[i] = CRGB(255, 255, 255);
}
for (int i = 60; i < 100; i++)/////////////Red-Back///////////////////
{
leds[i] = CRGB(255, 0, 0);
}
FastLED.show();
for (int j = 19; j >= 0; j--)////////////YellowRightturn///////////
{
leds[j] = CRGB(255, 255, 0);
leds[(NUM_LEDS/2-1)+((NUM_LEDS/2)-j)] = CRGB(255, 255, 0);
FastLED.show();
delay (BlinkerSpeed1);
}
for (int j = 19; j >= 0; j--)
{
leds[j] = CRGB(0, 0, 0);
leds[(NUM_LEDS/2-1)+((NUM_LEDS/2)-j)] = CRGB(0, 0, 0);
delay (BlinkerSpeed1);
}
}

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

What actually happens when you run your code ?
Have you got pullup or pulldown resistors in place to keep the inputs in a known state at all times ? I suspect not

Welcome to the forum.

Could you read this: How to get the best out of this forum
If you show your sketch, put it between code tags. Use the '</>' button or put the sketch between lines with three single backslash quotes:

```
Your sketch
```

Can you explain the problem ?
The sketch is doing something: a-very-long-title.ino - Wokwi Arduino and ESP32 Simulator

You don't have to: #include "Arduino.h"
That is already automatically included.

A variable for a pin number, can have "Pin" in its name. It prevents confusion. For example: switchPinA

The FastLED library takes care of the pin for the ledstrip, you don't have to set it as output with pinMode().

A digitalRead() returns HIGH or LOW, not 0 or 1. For example: if (digitalRead(SignalA) == LOW && ...

You could read the switches just once and put that in variables.

void loop() {
  int valueA = digitalRead(SignalA);
  int valueB = digitalRead(SignalB);
  int valueC = digitalRead(SignalC);

  if (valueA == LOW && valueB == LOW && valueC == LOW)
  {
    fullgreen();
  }
  ...

The sketch can be improved when you separate reading the buttons from writing to the leds. Then you need a extra global variable 'state' which tells the sketch what to send to the ledstrip and the buttons can set an other state.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.