Forum Index > Projects > LED Pegboard and Matrix Projects
 Mode switch between animation and solid-on mode using off switch
 |  Printable Version
By: bbum (offline) on Sunday, February 17 2008 @ 09:11 PM PST (Read 5989 times)  
bbum

I hacked up my peggybum.c a bit more.

It starts in "animation mode". That is, the board is animated as I described in the other thread.

If you hit the 'off' switch once, it turns on all LEDs (sort of like windows -- hit START to SHUTDOWN... only in reverse).

Hit the 'off' switch again, and the board goes to sleep / off as it did before.

There was actually a bit of trickery involved. Every time you hit the 'off' button, there are several pin change interrupts generated. If the first one executes a sleep instruction, no big deal... board goes dead and the rest of the signals are ignored.

Doesn't work so well when you want to mode change once before sleeping.

As I was too lazy to actually figure out how to implement a timer and do a proper debounce in code, I hacked in a global counter that is decremented down to 0 in the main() loop. Thus, when the interrupt is received, the signal handler checks to see if the global counter is zero -- if so, process the button -- if not, ignore and let main() keep running.

A bit hackish -- totally dependent on amount of time being spent during any given pass through main(), but it works well enough to allow me to avoid cracking a manual open.


Forum Henchperson
Henchperson

Status: offline

Registered: 01/23/08
Posts: 22

Profile Email    
   
By: bbum (offline) on Sunday, February 17 2008 @ 09:36 PM PST  
bbum

Forgot the URL:

http://svn.red-bean.com/bbum/trunk/avr/peggybum/


Forum Henchperson
Henchperson

Status: offline

Registered: 01/23/08
Posts: 22

Profile Email    
   



 All times are PDT. The time is now 02:58 PM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to Post 
Filtered HTML Allowed 
Censored Content 

Evil Mad Scientist Forum Archives — Read only!

Please visit our new forums for new discussions.


DIY Hardware for Electronic Art


The Original Egg-Bot Kit


Octolively
Interactive LED kits


Meggy Jr RGB
LED matrix game
development kit.


Business-card sized
AVR target boards


Peggy 2
LED Pegboard kits

My Account






Lost your password?