Device = 18F1220
Clock = 8
Config OSC = INTIO2
Include "INTOSC8.bas"
Include "Utils.bas" // local duty variable...
Dim sw0 As PORTB.0
Dim led As PORTB.3
Sub Debounce()
DelayMS(10) // Small delay to stop "bouncing"
While sw0 = 1 // Wait for the switch to be de-pressed
Wend //
End Sub
SetAllDigital
Input (sw0)
Output (led)
Low (led)
While true
If ( (sw0 = 1) And (led = 0) ) Then //check switch and led
led = 1 // turn on led
ElseIf( (sw0 = 1) And (led = 1) ) Then //check led to see if on ans switch
led = 0 // turn off led
EndIf
Wend