Forum Index > Projects > LED Pegboard and Matrix Projects New Topic Post Reply
 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 2904 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    
  Quote
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    
  Quote
Content generated in: 0.0229 seconds
New Topic Post Reply



 All times are PDT. The time is now 12:44 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 

Welcome to Evil Mad Scientist Laboratories. New projects are posted on most Wednesdays.


Bookmark EMSL

EMSL RSS

Evil Mad Linkblog

Twitter: @EMSL

Facebook page
del.icio.us
feedburner
Feed on Google Reader
YouTube Channel

Subscribe to get new articles by E-mail:

E-mail address:


Preview | Powered by FeedBlitz

My Account





Sign up as a New User
Lost your password?

Who's Online

Guest Users: 19

DIY Hardware for Electronic Art


Interactive LED Panel kits


Meggy Jr RGB
LED matrix game
development kit.


Business-card sized
AVR target boards


Peggy 2
LED Pegboard kits

Forumposts

Order: New Views Posts
Latest 10 Forum Posts
 
Re: Help me creating an arduin..
 By:  Windell
 Wednesday, September 01 2010 @ 07:08 PM PDT
Help me creating an arduino li..
 By:  x86.sll
 Wednesday, September 01 2010 @ 05:22 PM PDT
Re: Fourth Row of Green LED's ..
 By:  Windell
 Sunday, August 29 2010 @ 11:09 AM PDT
Re: Fourth Row of Green LED's ..
 By:  ChrisHale
 Sunday, August 29 2010 @ 08:11 AM PDT
Re: Fourth Row of Green LED's ..
 By:  ChrisHale
 Saturday, August 28 2010 @ 10:56 PM PDT
Re: Fourth Row of Green LED's ..
 By:  Windell
 Saturday, August 28 2010 @ 10:11 PM PDT
Fourth Row of Green LED's Stay..
 By:  ChrisHale
 Saturday, August 28 2010 @ 05:34 PM PDT
Re: Peggy2le serial video ques..
 By:  Windell
 Monday, August 23 2010 @ 11:53 PM PDT
Re: Peggy2le serial video ques..
 By:  milamber
 Monday, August 23 2010 @ 11:47 PM PDT
Re: Multiplexed, Super-long La..
 By:  Windell
 Monday, August 23 2010 @ 08:17 PM PDT