; ; Example program #2 for use with the OATLEY Electronics PICAXE Development System ; ; This program is an example of using a PICAXE 08M chip as a 12 volt lamp dimmer ; ; Author Jeff Monegal ; ; Microcontroller PICAXE 08M ; ; Compile date 27/4/2010 ; ;-------------------------------------------------------------------------------------------------- ; ; NOTES ; ; This is an operation program and the user can use all or part of it within their own programs ; ;-------------------------------------------------------------------------------------------------- ; symbol brightness = 1 symbol mosfet = 2 ;------------------------------------------------------------------------------------------------------------ low mosfet rem ensure the system starts with the mosfet off begin: readadc10 brightness,w6 rem read the brightness setting pot if w6 < 10 then stopped rem if value less than 10 turn lamp off pwmout mosfet,255,w6 rem turn on the lamp at a brightness as read from the pot rem PICAXE duty cycle (w6) is a 10 bit value which needs 2 bytes rem of 8 bits each hence w6 which is a 2 byte register goto begin stopped: pwmout mosfet,0,0 pause 50 goto begin ;------------------------------------------------------------------------------------------------------------