How are you setting B.1 low or high ?
are you using a button?
It looks like your "Switch" bounces when toggling.
means it very quickly changes between on and off before it reaches its final position.
The program is that fast that it detects this change.
you need to eliminate that "Key-bounce"
here is one possible way:
i Var Byte
Loop:
If PortB.1=1 Then 'Check HIGH on B.1
Pause 500 ' wait 500ms (you can certainly decrease the Pause time
If PortB.1=1 Then ' Is B1 still HIGH ?
High PortB.0
for i=1 to 60
Pause 1000
next
Low PortB.0
EndIf
EndIf
DoNothing:
If PortB.1=1 Then
Goto DoNothing
EndiF
Goto Loop
Key bounce is actually a "mechanical" problem you have to think of when working with buttons.
Your other questions were regarding basic BASIC stuff.
Now that you have got some examples try to modify the code.
i.e. use the BUTTON statement.




Bookmarks