Professional Documents
Culture Documents
Workshop 16F877 1sx
Workshop 16F877 1sx
S1 L1
S1 L1 S1
L1 Toggle
-------------------------------------------------S1
VAR PORTA.3
L1
VAR PORTB.5
ADCON1 = 7
Low L1
start: Input S1
IF S1 = 1 Then goto start
High L1
Pause 300
loop: Input S1
IF S1 = 1 Then goto loop
Low L1
Pause 300
GoTo start
End
Start
Set var and cons.
S1, L1
Input S1
Yes
S1 = 1 ?
.
No
L1 ON
.Delay 300 mS
Input S1
S1S1=1
=SS?1
No
L1 OFF
.Delay 300 mS
Yes
I/O
S1 L1
Reset
-----------------------------------------------------------------S1
VAR
PORTA.3
L1
VAR
PORTB.5
ADCON1 = 7
Low
PORTB.5
loop: Input S1
Pause 200
IF S1 = 1 Then loop
Pause 200
High
L1
End
Start
Set var and
cons.
Input S1
S1 = 1
.
No
L1 ON
End
Yes
S1 ( Loop1)
(Loop2) L1
-----------------------------------------------------------------S1
L1
Loop1:
Loop2:
VAR PORTA.3
VAR PORTB.5
ADCON1 = 7
Low PORTB.5
Input S1
Pause 200
IF S1 = 1 Then loop1
Pause 200
Input S1
IF S1 = 0 Then loop2
High L1
End
Start
Set var and cons.
S1, L1
Input S1
S1 = 1 ?
Yes
No
. Delay 200 mS
Input S1
S1 = 0 ?
No
.
L1 ON
End
Yes
4
Assignment no. 4
1 S1 L1 5
FOR .... NEXT FOR NEXT
-----------------------------------------------------------------Program 1
start:
For
S1
VAR
PORTA.3
L1
VAR
PORTB.5
I
VAR
BYTE
Low
L1
ADCON1 = 7
Input S1
IF S1 = 1 Then start
I = 1 to 5
High
L1
Pause 500
Low
L1
Pause 500
Next I
GoTo
End
start
---------------------------------------------------------------Program 2
S1
S2
L1
TRISA
I
start:
while
VAR
PORTA.3
VAR
PORTA.2
VAR
PORTB.5
= %11111111
VAR
BYTE
Low
L1
ADCON1 = 7
IF S1 = 1 Then start
pause 200
(S2 = 1)
High
L1
Pause 500
Low
L1
Pause 500
wend
goto start
end
2
S1 While
S2
While
L1
S2 While
(S2 = 1) While
Goto start
S1