🎁📬❄️📦Adafruit Holiday Shipping Deadlines 2019: Please place all UPS 2 Day orders by 11am Monday, December 16 📦❄️📬🎁
0

5 button color selector
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

5 button color selector

by superryan14 on Wed Nov 20, 2019 10:20 am

I mod guitar hero guitars with mechanical switches and LEDs in the 5 fret buttons (https://i.imgur.com/TjxZryX.jpg) Right now I use normal single color LEDs for the buttons. I wanted to switch them with neopixels and add a small button to enter a "color change mode" when held for a few seconds, then when one of the 5 fret buttons is pressed it will rotate through a set of colors (like 6 or 7 or something) for that button and repeat for each of the buttons. Then when the setup button is pressed again it will save it for next time. (Possibly saved when the guitar is unplugged as well but not too important if this makes it harder)

I don't know much coding but would love it if people would help with this or point me in the right direction on where I Can get something like this started.
superryan14
 
Posts: 16
Joined: Wed Feb 26, 2014 10:16 am

Re: 5 button color selector

by adafruit_support_mike on Thu Nov 21, 2019 2:08 am

The first place to start would be our NeoPixel Uberguide:

https://learn.adafruit.com/adafruit-neopixel-uberguide

That contains most of what we know about them. The next step would be to get some pixels and a microcontroller and start playing with them to get familiar with the toolchain and the code. We have breadboard-friendly versions that are good for experimentation:

https://www.adafruit.com/product/1312

And any microcontroller can generate the control signals you'll need. Our Metro 328 is 100% compatible with the Arduino Uno, and is a good board for getting started:

https://www.adafruit.com/product/50

adafruit_support_mike
 
Posts: 59708
Joined: Thu Feb 11, 2010 2:51 pm

Re: 5 button color selector

by superryan14 on Thu Nov 21, 2019 6:34 am

adafruit_support_mike wrote:The first place to start would be our NeoPixel Uberguide:

https://learn.adafruit.com/adafruit-neopixel-uberguide

That contains most of what we know about them. The next step would be to get some pixels and a microcontroller and start playing with them to get familiar with the toolchain and the code. We have breadboard-friendly versions that are good for experimentation:

https://www.adafruit.com/product/1312

And any microcontroller can generate the control signals you'll need. Our Metro 328 is 100% compatible with the Arduino Uno, and is a good board for getting started:

https://www.adafruit.com/product/50


Thanks for this! I read through the uberguide and understand most of the stuff from it, What I'm not getting is how to a color change "mode" to work. Like i'd like it if I could push a button it turns on all the LEDs and "unlock" the ability to rotate through the set colors but hitting one of the 5 buttons. then when I push the button again it turns them back off and "locks" that color change ability and keeps the colors selected
superryan14
 
Posts: 16
Joined: Wed Feb 26, 2014 10:16 am

Re: 5 button color selector

by kcl1s on Thu Nov 21, 2019 8:52 am

So where is your Arduino skill level. Do you know the basics? You give a pretty good description of what you want. You need to read a button presses https://www.arduino.cc/en/Tutorial/DigitalReadSerial, cycle through some colors (the code in this post shows how to use an Array to store colors and cycle through them) https://forums.adafruit.com/viewtopic.php?f=47&t=158778 and store color settings when turned off (look at the EEPROM library)https://www.arduino.cc/en/Reference/EEPROM

Hope this helps

Fellow hobbyist
Keith

kcl1s
 
Posts: 1365
Joined: Tue Aug 30, 2016 12:06 pm

Re: 5 button color selector

by superryan14 on Thu Nov 21, 2019 9:54 am

kcl1s wrote:So where is your Arduino skill level. Do you know the basics? You give a pretty good description of what you want. You need to read a button presses https://www.arduino.cc/en/Tutorial/DigitalReadSerial, cycle through some colors (the code in this post shows how to use an Array to store colors and cycle through them) https://forums.adafruit.com/viewtopic.php?f=47&t=158778 and store color settings when turned off (look at the EEPROM library)https://www.arduino.cc/en/Reference/EEPROM

Hope this helps

Fellow hobbyist
Keith


Thanks a ton! I'll look through all this and see what I can get! I am a beginner but I understand a decent amount but I dont know how to write stuff all that well.
superryan14
 
Posts: 16
Joined: Wed Feb 26, 2014 10:16 am

Re: 5 button color selector

by kcl1s on Thu Nov 21, 2019 11:29 am

Thanks a ton! I'll look through all this and see what I can get! I am a beginner but I understand a decent amount but I dont know how to write stuff all that well.

Best to get in there any give it a try. If you put something together and want help that is better than asking can you write this code for me.

Keith

kcl1s
 
Posts: 1365
Joined: Tue Aug 30, 2016 12:06 pm

Re: 5 button color selector

by kcl1s on Thu Nov 21, 2019 1:18 pm

Here is some test code my students made for a 'Simon' type game they made. Simple button code will show pressed while held down each time it is checked. This code only records new presses and ignores all positives until is senses a release. This can easily be changed for your 5 buttons.

Code: Select all | TOGGLE FULL SIZE
//4 button check example - will only return new presses
bool buttonState[] = {0, 0, 0, 0}; // Variable for reading the pushbutton status
bool oldButtonState[] = {1, 1, 1, 1}; //  Variable for old button state
const int buttonPin[] = {3, 5, 9, 11};       // button pin

void setup() {
  Serial.begin(9600);
  Serial.println("Start serial");
  for (int i = 0; i < 4; i++) {
    pinMode(buttonPin[i], INPUT_PULLUP);
  }
}

void loop() {
  int btnNumber = btnCheck();
  if (btnNumber > -1) {
    Serial.print(btnNumber);
    Serial.println(" highest pressed");
  }
}

int btnCheck() {
  int btnPressed = -1;    //will return -1 if no buttons pressed
  for (int i = 0; i < 4; i++) {
    buttonState[i] = digitalRead(buttonPin[i]);
    //Serial.print(buttonState);
    //Serial.println(oldButtonState);
    if ((buttonState[i] == LOW) && (oldButtonState[i] == HIGH)) {   //We have a new button press
      //Put button press code here     
      btnPressed = i;   // mark as pressed- will only return last positive check if multi presses
      //--------------------------
      oldButtonState[i] = LOW;
    }
    else if ((buttonState[i] == HIGH) && (oldButtonState[i] == LOW)) {  //We have a button release
      oldButtonState[i] = HIGH;
    }
  }
  delay(50);    //for button debounce
  return btnPressed;    //return which button is pressed
}


Keith

kcl1s
 
Posts: 1365
Joined: Tue Aug 30, 2016 12:06 pm

Please be positive and constructive with your questions and comments.