Pages: [1]   Go Down
Author Topic: Changing led sequence with buttons  (Read 334 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Queens, New York
Online Online
Faraday Member
**
Karma: 108
Posts: 3785
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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(led1,HIGH);
digitalWrite(led2,LOW);
digitalWrite(led3,HIGH);
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.
« Last Edit: November 21, 2012, 07:35:51 am by HazardsMind » Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Poole, Dorset, UK
Offline Offline
Edison Member
*
Karma: 52
Posts: 2395
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Mark
Logged

Queens, New York
Online Online
Faraday Member
**
Karma: 108
Posts: 3785
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wait I for got something, it would be 0x0AAA not just 0AAA.
Logged

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

Pages: [1]   Go Up
Jump to: