Washing Machine Alert — first project

Hi all,

I have been lurking around in the background for some time now, reading and learning, and recently I built my first project :D

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!

Photo 05-04-2013 19 58 29.jpg

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 &#937; 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
 

westaust55

Moderator
At the end of the Alert code section you have a GOSUB Noise command.
However at the end of the Noise routine you use GOTO Alert.

I recommend that you change that last line from GOTO Alert to
RETURN

Otherwise the code stack fills up with GOSUB return address data and never clears so the stack will overflow.
 

westaust55

Moderator
Had another look now in front of a pC.

Can I suggest that you also add
GOTO Main
as a new line just before the label Unlocked:

otherwise you test for >100 and < 70, but if the result is from 70 to 100 inclusive it fall through into the unlocked code section.


ALSO:
Welcome to the PICAXE forum
 

TAMeyer

Member
What a crafty and elegant use of polymorph.

It looks like a supported accessory from the manufacturer, similar to molded IR extenders for stereos.
 
Thank-you very much TAMeyer!

I moulded the bulk of it with a stainless-steel measuring spoon to keep it smooth.

I'd spent weeks looking round to find some off-the-shelf component to do the job, and the daftest thing is that I already had the Polymorph..!
 

boriz

Senior Member
Nice project. Did something similar with a gas water heater once. Mine looked like crap though.

Polymorph rocks.

Saw another great way of using it recently. User needs 8 LEDs on a simple sound sequencer to show which of the 8 notes in the sequence is currently playing. He drilled 8 holes, about 1cm diam, in a line on the front panel. Put tape on the 'front' side of the panel to cover all the holes, then squeezed molten polymorph into each hole from the back while the front was on a flat surface. Before it set, an LED was pushed into the back of each. Then removed the tape. The result looks very professional. A line of 1cm, perfectly flush white disks that glow evenly when lit. Sweet.
 
Top