Neopixel push switch control with UNO 3

Hi , very new to Arduino but worked with electronics for many years. I have built a arcade cabinet and works great but need to add lighting for a trackball and spinners. I have some neopixels and a arduino uno v3. I would like to get the UNO to turn on the RED , GREEN or BLUE leds via 3 input switches. I downloaded a neopixel program that displayed colours and patterns via a one input push switch that pulls pin 4 low to change pattern / colours.

I have removed all the lines that i do not need but would like some help on how to add the 3 input switches. The program now starts blank and turns the leds on red(first press) then green(second press) and blue (third press) and working ok. I just need to be able to turn the red , green and blue on or off via 3 input switches to the UNO. I can then control these inputs via mt ipac cotroller for the arcade machine. I think this will be easy for members that are used to programming these.

this is what i have working but the switch only cycles RGB colours where i need a input switch for each colour.The colours i have set low while testing this project.

Thank you for your help

// Simple demonstration on using an input device to trigger changes on your
// NeoPixels. Wire a momentary push button to connect from ground to a
// digital IO pin. When the button is pressed it will change to a new pixel
// animation. Initial state has all pixels off -- press the button once to
// start the first animation. As written, the button does not interrupt an
// animation in-progress, it works only when idle.

#include <Adafruit_NeoPixel.h>
#ifdef AVR
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

// Digital IO pin connected to the button. This will be driven with a
// pull-up resistor so the switch pulls the pin to ground momentarily.
// On a high -> low transition the button press logic will execute.
#define BUTTON_PIN 2
#define BUTTON_PIN 3
#define BUTTON_PIN 4

#define PIXEL_PIN 6 // Digital IO pin connected to the NeoPixels.

#define PIXEL_COUNT 12 // Number of NeoPixels

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)

boolean oldState = HIGH;
int mode = 1; // Currently-active animation mode, 1-3

void setup() {
pinMode(BUTTON_PIN, INPUT_PULLUP);
strip.begin(); // Initialize NeoPixel strip object (REQUIRED)
strip.show(); // Initialize all pixels to 'off'
}

void loop() {
// Get current button state.
boolean newState = digitalRead(BUTTON_PIN);

// Check if state changed from high to low (button press).
if((newState == LOW) && (oldState == HIGH)) {
// Short delay to debounce button.
delay(20);
// Check if button is still low after debounce.
newState = digitalRead(BUTTON_PIN);
if(newState == LOW) { // Yes, still low
if(++mode > 3) mode = 1; // Advance to next mode, wrap around after #3
switch(mode) { // Start the new animation...

    case 1:
      colorWipe(strip.Color(1,   0,   0), 0);    // Red
      break;
    case 2:
      colorWipe(strip.Color(  0, 1,   0), 0);    // Green
      break;
    case 3:
      colorWipe(strip.Color(  0,   0, 1), 0);    // Blue
      break;
    
  }
}

}

// Set the last-read button state to the old state.
oldState = newState;
}

// Fill strip pixels one after another with a color. Strip is NOT cleared
// first; anything there will be covered pixel by pixel. Pass in color
// (as a single 'packed' 32-bit value, which you can get by calling
// strip.Color(red, green, blue) as shown in the loop() function above),
// and a delay time (in milliseconds) between pixels.
void colorWipe(uint32_t color, int wait) {
for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
strip.setPixelColor(i, color); // Set pixel's color (in RAM)
strip.show(); // Update strip to match

Hello 540itouring

Welcome to the worldbest forum.

We need some additional information.

Post your sketch, well formated, with well-tempered comments and in so called code tags "< code >" and a real schematic to see how we can help.

Have a nice day and enjoy coding in C++.

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