0

Ok I'm stupid when it comes to coding. I have a simple project that I need some help with. Is it possible to make neopixle change what animation runs via multiple switches. Example they stay off till switch is flipped then if a different switch is flipped they run a different animation and vice versa.

3
  • Can you show us the code you have written so far?
    – VE7JRO
    Oct 2, 2018 at 0:16
  • There is too much unspecific language (e.g. "change what animation runs", "stay off") that it's hard to work out what you are actually asking. Also no need to write at the start of your post "I'm stupid when it comes to coding". You're not, everyone has problems to solve, that's why this site exists. Consider editing your question also taking into account VE7JRO's comment.
    – MichaelT
    Oct 2, 2018 at 7:35
  • I get so confused with this stuff lol. What I wanted is the pixels to stay off then when a switch is flipped it does a color wipe and they stay on. Then if another switch is flipped they do a continuous color wipe. And the same in the reverse sequence.
    – Gcompston
    Oct 3, 2018 at 0:50

1 Answer 1

0

Yes absolutely it is possible. As a beginner, I suggest something like this:

schematic

simulate this circuit – Schematic created using CircuitLab

In your setup you will need to declare D4 - D7 as inputs. I have used D4 - D7 but you can choose whatever pins are available.

Then in the loop part of the code you want to look for the rising edge on the input (ie when the switch is pressed). Switch debounce is less important for this application as it is not a counter but rather a mode change.

I have written a good answer for detecting a button press here.

Nick Gammon has an excellent switch tutorial gammon.com.au/switches that covers all kinds of conceivable situations (high or low, GND or +5V, internal pull-up or pull-down, capacitor debounce or software debounce, etc.)

I would imagine the code would look something like this:

if( digitalRead(SW1) == HIGH )
    mode = 1;

if( digitalRead(SW2) == HIGH )
    mode = 2;

if( digitalRead(SW3) == HIGH )
    mode = 3;

if( digitalRead(SW4) == HIGH )
    mode = 4;

You could then use a switch-case statement to run the various NeoPixel patterns.

For more programming reference see: https://www.arduino.cc/reference/en/

6
  • Thanx makes it much more understandable
    – Gcompston
    Oct 3, 2018 at 0:47
  • This is driving me nuts lol. does anyone know somewhere i can pay someone to write arduino code.
    – Gcompston
    Oct 15, 2018 at 5:09
  • The Arduino Forum has a Gigs and Collaborations section where you can offer to pay to have code written for you. However if you just want a fancy light show, you can buy those off the shelf, if you aren't interested in learning the programming side of things.
    – Nick Gammon
    Oct 17, 2018 at 6:19
  • I would like to learn it. Just got frustrated with it for a awheil. I'm trying to make lights for a golf cart. Just like a car has stop,tail,and turn signals. I get close then mess it up to the point it doesn't work anymore lol
    – Gcompston
    Oct 18, 2018 at 7:19
  • We can do code reviews here on Arduino Stack Exchange. Just add the code review tag to the question you ask.
    – sa_leinad
    Oct 18, 2018 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.