RacingtoMars
Member
Hi all,
I have been lurking around in the background for some time now, reading and learning, and recently I built my first project
Our new washer doesn't have an audible alert unlike our previous one, and this is pretty much all this device provides.
It monitors the door-lock LED so that it can discriminate between the end of a cycle versus the washing machine not having started yet. Monitoring the "Cycle End" LED on the washer's panel would cause false triggers, for example when first switched on.
There is a 'sensor' housed in Polymorph (shown in the photo) which is a mini LDR to sense the door-lock light of the washer, plus a pink LED to indicate the door is locked now that my sensor covers up the machine's!
Prior to discovering the world of Picaxe I would have built this out of discrete components, logic gates, relays, cardboard tubes and string…
I'm no programmer and would welcome feedback and tips to make the code neater / slicker / more efficient and elegant (or just less rubbish!)
Thanks & best regards,
Craig.
I have been lurking around in the background for some time now, reading and learning, and recently I built my first project
Our new washer doesn't have an audible alert unlike our previous one, and this is pretty much all this device provides.
It monitors the door-lock LED so that it can discriminate between the end of a cycle versus the washing machine not having started yet. Monitoring the "Cycle End" LED on the washer's panel would cause false triggers, for example when first switched on.
There is a 'sensor' housed in Polymorph (shown in the photo) which is a mini LDR to sense the door-lock light of the washer, plus a pink LED to indicate the door is locked now that my sensor covers up the machine's!
Prior to discovering the world of Picaxe I would have built this out of discrete components, logic gates, relays, cardboard tubes and string…
I'm no programmer and would welcome feedback and tips to make the code neater / slicker / more efficient and elegant (or just less rubbish!)
Thanks & best regards,
Craig.
Code:
' Washing Machine Cycle End Alert by Craig Marston
' === Constants ===
symbol pinkLED = C.0 ; the LED signifying the door is locked
symbol strobe = C.4 ; über-bright green LED for visual alarm
' === Directives ===
#com /dev/tty.usbserial-0000201A ' specify serial port
#picaxe 08M2 ' specify processor
pause 500
main: ;label
readadc C.1,b0 ;read adc into variable b0
if b0 > 100 then locked ;if LDR Ω is low (LIGHT on) subroutine locked
if b0 < 70 then unlocked ;if LDR Ω is high (DARK) then subroutine unlocked
locked:
high pinkLED ;signifies the door locked
low strobe ;ensures green LED is off
readadc C.1,b0 ;read the LDR
pause 500 ; pause 0.5 s
if b0 < 70 then alert ; (DARK) cycle finished so jump to alert subR
goto locked ; else stay in locked subR
unlocked: ; this subR blinks the LEDs to show the device is powered on
low pinkLED ;door unlocked so pink LED off
high strobe ; green LED
pause 2 ; flashes
low strobe ; to notify system is switched on
pause 100
high pinkLED
pause 2
low pinkLED
pause 2500
goto main ; continue monitoring
alert: ; it all kicks off here
b3 = 0
do
low pinkLED ; door is unlocked
high strobe ; über-bright green LED
pause 50
low strobe
pause 100
high strobe
pause 50
low strobe
pause 100
high strobe
pause 50
low strobe
inc b3
pause 500
loop while b3 < 10
gosub noise
;stuck in this subroutine until powered off…
noise: ; a sound of incrementing pitch
for b1 = 110 to 127
sound C.2, (b1,5)
next b1
goto alert