Good morning this is my first post and would be grateful for any assistance with my code that will not do what I expect. I have split the code into two i.e. TOUCH and PWM and both work ok on their own.
The touch code is based on AXE181 data sheet and uses 25mm sq plates, the PWM on VSHOTT post of 22-07-2011 PWM FAN. The idea is to dim 2 surplus white LED strip lighting units via a Picaxe 20M2 using touch plates switches controlling a n- channel Mosfet via PWM.
The original PWM Circuit used two switches to ground the pull up resistors on B.0 and B.1
The code appears to simulate in PE and loads with no problems but when run the output on C.5 just stays static at a constant PWM output. Two chips have been tried. Many thanks.
Code
The touch code is based on AXE181 data sheet and uses 25mm sq plates, the PWM on VSHOTT post of 22-07-2011 PWM FAN. The idea is to dim 2 surplus white LED strip lighting units via a Picaxe 20M2 using touch plates switches controlling a n- channel Mosfet via PWM.
The original PWM Circuit used two switches to ground the pull up resistors on B.0 and B.1
The code appears to simulate in PE and loads with no problems but when run the output on C.5 just stays static at a constant PWM output. Two chips have been tried. Many thanks.
Code
Code:
'20m2
main:
touch16 C.2, w2 ;UP read sensor C.2 into word variable w2
if w2 > 5500 then
low B.0
else
high B.0
end if
touch16 c.3, w3 ; DOWN read sensor C.3 into word variable w3
if w3 > 5500 then
low B.1
else
high B.1
end if
Symbol Duty = W0
Duty = 400 ' start with medium duty
PWMOut C.5, 249, Duty
TOP:
GoSub Flash ' flash the LED on Out0
If PinB.0 = 0 and PinB.1 = 0 Then StopPWM ' if both pushbuttons depressed
If PinB.0 = 0 and PinB.1 = 1 Then Slower ' if one depressed
If PinB.0 = 1 and PinB.1 = 0 Then Faster ' if other depressed
' no change if neither depressed.
GoTo TOP ' continually loop
StopPWM:
PWMOut C.5, 0, Duty ' zero the period
GoTo TOP
Slower:
If Duty < 20 Then Top ' minimum floor
Duty = Duty - 15 ' decrease duty
PWMOut C.5, 250, Duty
Pause 100
GoTo TOP
Faster:
If Duty > 984 Then Top
Duty = Duty + 15 ' increase duty
PWMOut C.5, 250, Duty
Pause 100
GoTo TOP
Flash: ' flash LED on Out0
High C.7
Pause 100
Low C.7
Pause 100
Return
goto main ; loop