'DemoPic.bas
' Primjer rada sa ulazima i izlazima
' 4 ulaza RA0 - RA3 (pritiskom na taster spajamo ulaz na masu)
' 1 izlaz za paljenje releja RA4 (pali ga logicka jedinica)
' 8 izlaza ,led diode , RB0 - RB7 ,jedinica pali diodu.
' sada palimo svih 8 led jednu po jednu svakih 1 sekunde
demo:
gosub paliDiode
gosub gasiDiode
gosub paliRelej
gosub gasiRelej
input portA.0
input portA.1
input portA.2
input portA.3
loopTasteri:
if portA.0 = 0 then gosub taster1 'pali relej
if portA.1 = 0 then gosub taster2
if portA.2 = 0 then gosub taster3
if portA.3 = 0 then goto taster4
gosub blink2to5
goto loopTasteri
goto demo
blink2to5:
portb.2 = 1
portb.3 = 1
portb.4 = 1
portb.5 = 1
pause 100
portb.2 = 0
portb.3 = 0
portb.4 = 0
portb.5 = 0
pause 100
return
taster1:
high portA.4
return
taster2:
portb.0 = 1
portb.1 = 1
return
taster3:
portb.6 = 1
portb.7 = 1
return
taster4:
portb.0 = 0
portb.1 = 0
portb.6 = 0
portb.7 = 0
portA.4 = 0
pause 1000
if portA.3 = 0 then goto demo
goto loopTasteri
paliRelej:
high portA.4
pause 1000
return
gasiRelej:
low portA.4
return
paliDiode:
high portb.0 'palim diodu
pause 1000 'pauza 1 sekunda
high portb.1 'palim diodu
pause 1000 'pauza 1 sekunda
high portb.2 'palim diodu
pause 1000 'pauza 1 sekunda
high portb.3 'palim diodu
pause 1000 'pauza 1 sekunda
high portb.4 'palim diodu
pause 1000 'pauza 1 sekunda
high portb.5 'palim diodu
pause 1000 'pauza 1 sekunda
high portb.6 'palim diodu
pause 1000 'pauza 1 sekunda
high portb.7 'palim diodu
pause 1000 'pauza 1 sekunda
return
gasiDiode:
portb.7 = 0 ' gasim diodu
pause 1000
portb.6 = 0 ' gasim diodu
pause 1000
portb.5 = 0 ' gasim diodu
pause 1000
portb.4 = 0 ' gasim diodu
pause 1000
portb.3 = 0 ' gasim diodu
pause 1000
portb.2 = 0 ' gasim diodu
pause 1000
portb.1 = 0 ' gasim diodu
pause 1000
portb.0 = 0 ' gasim diodu
pause 1000
return
'****************************************************************
'* Name : DemoSer.BAS *
'* Author : Vizler Rainhold *
'* Notice : Copyright (c) 2002 [set under view...options] *
'* : All Rights Reserved *
'* Date : 11/6/02 *
'* Version : 1.0 *
'* Notes : Primjer serijske komunikacije *
'* : *
'****************************************************************
' RB2 je Txd (linija za slanje podataka )
' RB1 je Rxd (linija za primanje podataka)
include "modedefs.bas" 'potrebno za serijsku komunikaciju
ulaz var byte
input portA.0
input portA.3
loop:
gosub blink3
if portA.0 = 0 then gosub helloworld
if portA.3 = 0 then goto primaj
goto loop
blink3:
high portb.3
pause 100
low portb.3
pause 100
return
helloworld:
Serout portb.2,N9600,["Hello,World!",13,10]
high portb.7
pause 300
low portb.7
pause 300
return
primaj:
high portb.3
Serin portb.1,N9600,ulaz
if ulaz = "x" then goto loop ' izlaz ako smo primili x
if ulaz = "1" then goto pali
if ulaz = "0" then goto gasi
goto primaj
pali:
high portb.6
goto primaj
gasi:
low portb.6
goto primaj