Go Down

Topic: Changing led sequence with buttons (Read 549 times) previous topic - next topic


I was wondering if any anyone could help me, I have an array of LEDs that I would like to animate however I want to have 4 buttons which change the led's animation. I was unsure of the best way to do this. I was thinking of having the buttons change a variable when pressed and then a Switch case check what the variable is.


Nov 21, 2012, 01:32 pm Last Edit: Nov 21, 2012, 01:35 pm by HazardsMind Reason: 1
You may be able to set the output as a byte and when a button is pressed it changes the byte being outputed.

Button1: byte:01010101
Button2: byte:00110011
Button3: byte:11001100
Button4: byte:10101010

Im not sure if the I/O pins can be turned on like that, or not, but it is worth a try as opposed to:
digitalWrite(led4,LOW);  and so on.

try sending out a byte and see if it works.

Actually im curious as to see if:
digitalWrite(0AAA,HIGH); //0AAA = 0000|1010|1010|1010 as a 13 pin byte
I doubt it will work but, it would nice if it did.
My GitHub:


Post your existing code. If you haven't already look at blink without delay and button debouncing.



Wait I for got something, it would be 0x0AAA not just 0AAA.
My GitHub:

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131