Symphony LED with Buttons

Could someone help tell me if this is possible?
I wanted to install a symphony LED bead kit in my car. The link below

https://www.aliexpress.us/item/3256804110174745.html?pdp_npi=4%40dis!USD!US%20%2453.34!US%20%2453.34!!!53.34!53.34!%402101fb0c17098339288958608edc66!12000029398899934!sh!US!1966726149!&spm=a2g0o.store_pc_allItems_or_groupList.new_all_items_2007560602014.1005004296489497&gatewayAdapt=glo2usa

I also want to add 2 or 3 buttons
I want these specific Buttons and set them up to control specific color settings of my choice
Not sure what would be best, Momentary or Latching

https://www.aliexpress.us/item/3256803846885450.html?spm=a2g0o.cart.0.0.36417a9dhGpWH9&mp=1&gatewayAdapt=glo2usa

If this is possible what kind of arduino is best, and do I need resistors, voltage converters etc?

Thank you

One of the images in the link shows a "host power cord / touch button." Probably just to cascade through pre-programmed displays... like this...

Thank you, can you help me make a few changes please with coding, I want to have 3 total buttons, 1 for Red, 2 for White, and 3 for completley random addressable colors to change.

Show your sketch.

the sketch you made was perfect except its one button, not sure what pins i can use the other 2 buttons, and how to code them.

I use a Nano and Uno. In the sketch in post #2, I used an interrupt on pin 2.

There is only one more interrupt pin remaining to use the same mechanism on pin 3. Other boards have more hardware interrupt pins.

You could read about Pin Change interrupts to use more interrupts.

You could also use a button library, like ezButton (find it in your IDE library, with examples).

You could also not use any of these and use ONE button to do many things by programming "short press" and "long press" and "multiple press" functions.

Most of your projects will want a means to start and stop. Try them all.

Ok so I took your advice, and have been doing alot of research, unfortunalty I couldn't figure out how to code the ezButton you suggested however you did give me a lot of different ideas I wasn't aware of before, so after many hours of trying to code this is what I came up with, 2 buttons basically one to change LEDs to Red and the other button to White, if you can please tell me how I can code the press and hold the "Red" button to make brightness higher and click and hole "White" button to dim. Here's my code which works fine without brightness.

Thanks again for all your help


#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 RED   2
#define WHITE 3
#define PIXEL_PIN    6  // Digital IO pin connected to the NeoPixels.
#define PIXEL_COUNT 16  // Number of NeoPixels


// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);

boolean oldState = HIGH;
int     mode     = 0;    // Currently-active animation mode, 0-9

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

  pinMode(PIXEL_PIN, OUTPUT);
  // init serialize communication at 9600 bits per second
  Serial.begin(9600);
}


void loop() {

  // Get current button state.
  boolean newState = digitalRead(RED);
  boolean newState2 = digitalRead(WHITE);

  // 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(RED);
    if(newState == LOW) {      // Yes, still low
      if(++mode > 0) mode = 0; // Advance to next mode, wrap around after #8
      switch(mode) {           // Start the new animation...
        case 0:
          colorWipe(strip.Color(  255,   0,   0), 50);    // Red
          break;
      }
    }
  }
// Check if state changed from high to low (button press).
  if((newState2 == LOW) && (oldState == HIGH)) {
    // Short delay to debounce button.
    delay(20);
    // Check if button is still low after debounce.
    newState2 = digitalRead(WHITE);
    if(newState2 == LOW) {      // Yes, still low
      if(++mode > 1) mode = 0; // Advance to next mode, wrap around after #8
      switch(mode) {           // Start the new animation...
        case 0:
          colorWipe(strip.Color(255,   255,   255), 50); // White
          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
    delay(wait);                           //  Pause for a moment
  }
}
type or paste code here

This is an example of how I'd set it up, except the LED strips will be using external power since they're 12v

Your button press is using "delay()" to debounce the button which will get in the way of timing needed for the long press to work. Take a look at a few "arduino button short press long press" and compare their methods They usually start a timer when the button is pressed, then use the timer to determine if the bouncing is done, then keep track of how long the button has been pressed to determine short or long press.

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