Josh’s tech art and sound blog


My code
May 4, 2006, 3:21 am
Filed under: Project Stuff

global [val0 val1 val2 val3 val4 val5]

to powerup
Write portb-ddr $00 ;set all of portb as outputs

loop[
setval0 (read-ad 0) ;sets value of photoresistor to variable valX
print val0
wait 2
setval1 (read-ad 1)
print val1
wait 2
setval2 (read-ad 2)
print val2
wait 2
setval3 (read-ad 3)
print val3
wait 2
setval4 (read-ad 4)
print val4
wait 2

if (val0 < 1020) ;if the value of the photoresistor is under a certain level ground the chip to set off speaker
[
setbit 0 portb
clearbit 0 portb
wait 1

]
if (val1 < 1020)
[
setbit 1 portb
clearbit 1 portb
wait 1
]
if (val2 < 1020)
[
setbit 2 portb
clearbit 2 portb
wait 1
]
if (val3 < 1020)
[
setbit 3 portb
clearbit 3 portb
wait 1
]
if (val4 < 1020)
[
clearbit 4 portb
wait 1
]
if (val4 < 1020) ;for dimmer activate chip for 30 seconds and then reverse polarity for 30 seconds then clear both bits
[
setbit 5 portb
clearbit 6 portb
wait 100
clearbit 5 portb
setbit 6 portb
wait 100
clearbit 6 portb
wait 1
]
]
end


No Comments Yet so far
Leave a comment



Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>