BasicMicro - Forums

www.basicmicro.com
It is currently Mon May 21, 2012 12:11 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Halloween and the Nano Simon Board
PostPosted: Mon Oct 25, 2010 4:45 pm 
Offline
Master

Joined: Sun Aug 17, 2008 5:26 pm
Posts: 798
Location: CA bay Area
I bought a 97 cent plastic pumpkin at Wal Mart for Halloween. I wanted to put something inside that would "fake" a flickering candle so little children wouldn't burn themselves if they decided to have a look or just stick a hand inside. Since the Nano Simon Board has eight LEDs in a bank, and two 7-segment LED displays, I figured that had plenty of potential.

I whomped up a program to turn all these LEDs on and off in a seemingly random way, and comes close to the random flickering of a candle. In a dark room, with the board hung to the back of the "pumpkin", and at just the right heighth within, the flicker appears to be just behind the nose. The "pumpkin's" thin plastic diffuses the LEDs just enough to appear as a single source of light. I will solder a 2.1mm power plug onto a 9V battery plug and run the board off that on the big night. How long will that last? Can't say. 'Long enough, I hope.

Unfortunately, I can't find the ding-blasted Aiptek digital camcorder to record this project and post it on YouTube. Take my word for it, it works good!

Unlike all my previous code, there is no commenting. Suffice it to say, between IF-THEN conditionals to produce different time outs, and using bitbang serial outputs to "break up" the LED signals, this does the job rather nicely. My big regret is I couldn't get a wierd, unearthly sound out of this! All the timeouts and tight timings simply didn't allow a long blast out of the speaker. Pfft!
If you need it to figure out the workings of the code, here's the data sheet, which contains the schematic:
http://downloads.basicmicro.com/downloads/datasheets/7seg_led_Simon_game_Nano_B0117.pdf
Enoy!
Code:
;102410 - Pumpkin Candle Proxy - kenjj
I var byte
V var byte

HIGH 13
HIGH 0
LOW 1
HIGH 2
LOW 3
HIGH 4
LOW 5
HIGH 6
LOW 7

WHILE 1
FOR V = 0 to 250
FOR I = 0 to 7
HIGH 13
TOGGLE I

IF V // 2 = 0 then
HIGH 8
ENDIF

IF V // 5 = 0 then
HIGH 9
ELSE
HIGH 8
ENDIF

IF V // 3 = 0 then
LOW 8
LOW 9
PAUSE 30
ENDIF

IF V // 10 = 0 then
HIGH 8
HIGH 9
HIGH 13
OUTL = %1111
OUTH = %1111
ENDIF

IF I//2 = 0 then
PAUSE 3  ; 300
ENDIF

IF I//3 = 0 then
PAUSE 5
ENDIF

IF I//5 = 0 then
PAUSE 7
ENDIF

SEROUT I, N57600, [1*I,3*I,5*I,7*I,10*I]

SEROUT I, I57600, [1*I,3*I,5*I,7*I,10*I]

LOW 8
LOW 9
NEXT  ; I

IF V//2 = 0 then
OUTH = %1111
ENDIF

OUTL = %1111

NEXT  ; V

WEND

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO