Professional Documents
Culture Documents
'lseif )7 = 1 And B_ = 1 "#en B_ = 0 'lseif A = 300 "#en : ,osu0 .om1a2e 'nd If 8aitms 6 *e9t A /etu2n '-------------------------------------------------------.om1a2e: .ls If Jmld_jantung := ;< And Jmld_jantung == ;0 "#en Lo$ate 1 , 1 L$d & (>*DI)I JA*"+*, A*DA: & 'analisa 1 Lo$ate 1 , 1? L$d & DALAM ('ADAA* *>/MAL& '============================================= 'lseif Jmld_jantung = ?< "#en Lo$ate 1 , 1 L$d & (>*DI)I JA*"+*, A*DA & Lo$ate 1 , 1? L$d & DALAM ('ADAA* L'MA@& 'lseif Jml_jantung : 11 "#en '============================================= Lo$ate 1 , 1 L$d & (>*DI)I JA*"+*, :& Lo$ate 1 , 1? 'analisa 3 L$d & DALAM ('ADAA* + *>/MAL A "I*,,I & 'nd If 8aitms 1000 '============================================= .ls ,oto Mulai_1 '------------------------------------------------------
'analisa 6
MATERI
MENGENAL INSTRUKSI BASCOM PEMOGRAMAN OUTPUT LED
DATA INPUT / OUTPUT PORT OPERASI SHIFT T SHIFT LEF SHIFT RIGHT OPERASI COUNTER UP COUNTER DOWN COUNTER UP-DOWN COUNTER PEMOGRAMAN OUTPUT DIPSLAY OUTPUT 7 SEGMENT OUTPUT LCD
Directives Directives are special instructions for t e co!piler" T e# can overri$e a settin% fro! t e IDE" #IF , #ELSE , #ENDIF , $ASM - $END ASM ,$INCLUDE , $BAUD , $BGF , $CRYSTAL , $DEFAULT XRAM , $IRAMSTART , $LARGE , $LCD , $MAP , $NOBREAK , $NOINIT , $NONAN , $NONULL , $NORAMCLEAR , $NOSP , $OBJ , $RAMSI E , $RAMSTART , $REGFILE , $ROMSTART , $SERIALINPUT , $SERIALINPUT!LCD , $SERIALOUTPUT , $SIM Graphical LCD Graphical CD commands extend the normal text CD commands. !"#$ % "&'W!(C I2C ()C commands allow you to communicate with ()C chips with the $W( hardware or with emulated ()C hardware. ()C*#C#(+# % ()C"#,D % ()C"$A*$ % ()C"$'! % ()C*-.$# % ()CW-.$# Interrups (nterrupt related routines. ', (nterrupt % #,A- # % D("A- # % !*('*($. IO (/' commands are related to the (/' pins of the processor. A (A" % -($WA($ % D#-'0,C# % "#$ % *#"#$ Math 1ath functions A-" % A+G % 1A2 % 1(, % 1'D Micro 1icro statements are highly related to the micro processor. -*#A3 % !1%!4 % (D # % #,D % !'W#*D'W, % "$A*$ % "$'! % "$'! $(1#* Me ory Me!or# functions set or rea$ RAM & EE'ROM or flas !e!or#"
C'EEK & ERASE & IN' & OUT & 'EEK & 'OKE & DIM & READ & RESTORE & DATA & (AR'TR Re ote control *emote control statements send or receive (* commands for remote control. G#$*C5 R!"2#2 *"6)4) are serial routines that use the 0A*$ or emulate a 0A*$. WA($3#. % !*(,$ % !*(,$-(, % !*(,$ % !0$ % '!#, %"!C % (,3#. % (,!0$ % (,!0$-(, % (,!0$ % G#$ % C '"# !$I "!( routines communicate according to the "!( protocol with either hardware "!( or software emulated "!(. "!((, % "!('0$ % "!((,($ !tring "tring routines are used to manipulate strings. 1(D % CA"# % (,"$* % #7$ % #, % *(G&$ % "$*(,G % *#! AC# % "!AC# % 0CA"# %e&t LCD $ext CD routines wor8 with the normal text based CD displays. C " % C0*"'* % 7'0*$& (,# % &'1# % CD % CD(,($ % CD % 'CA$# % "&(7$ CD % "&(7$C0*"'* %D("! A. % 'W#* (,# % 0!!#* (,# % $&(*D (,#
'arious
$his section contains all statements that were hard to put into another group CA , C',"$ , C'0,$#* , D#C* , D#C A*# , D#7(,$ , D#7-($ ,D#7-.$# , D#7 CDC&A* , D#7W'*D , G#$AD , G#$AD)951 , G#$*C , , G'"0- , G'$' , (,C* , 'AD , ''30! , ''30!"$* , 'W , 'WW , ', +alue , *#AD1AGCA*D , *#1 , *#$0*, , *,D , *'$A$# , "&(7$ , "&(7$(, , "&(7$'0$ , "'0,D , "0- , "WA!
) ) ) ) ) ) )
1 + , 8 1. -+ .,
) ) ) ) ) ) )
Catatan
PROGRAM UP-COUNTER
PENJELASAN INSTRUKSI
DIM
Dimension a variable.
Syntax
DIM var AS [XRAM/IRAM] type
Remarks
Var !ype ()A* %)A* Any valid variable name such as b1, i or longname. var can also be an array : ar(10) for e ample. "it#"oolean, "yte, $ord, %nteger, &ong, 'ingle or 'tring 'pecify ()A* to store variable in e ternal memory 'pecify %)A* to store variable in internal memory (default)
A string variable needs an additional parameter that specifies the length of the string: Dim s As ()A* String * 10 %n this case, the string can have a length of 10 characters. +ote that "%!' can only be stored in internal memory.
Difference with Q
%n ," you don-t need to dimension each variable before you use it. %n "A'./* you must dimension each variable before you use it. Also the ()A*#%)A* options are not available in ,".
See A!s"
./+'! , 0)A'0
#xam$!e
,"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" , , file3 DIM4*(! , de o3 DIM ,"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Di Di Di Di Di *1 (s *it ( (s *yte C (s Integer L (s Long ! (s !ingle ,or ,use set ,5it can 5e 1 or 1 ,5yte range fro 1"200 "#2626 " 7#2628 ,integer range fro -c. 1//0"2112 MC! Electronics ,""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
,(ssign 5its *1 9 1 !et *1 ,(ssign 5ytes ( 9 12 ( 9 ( 7 1 ,(ssign integer C 9 "12 C 9 C 7 111 $rint C ,(ssign long L 9 12#:0268 $rint L ,(ssign single ! 9 12#:4026 $rint ! End
DO C LOOP
Acti"n
)epeat a bloc1 of statements until condition is true.
Syntax
D% 'tatements &%%' [ ()*I& e pression ]
Remarks
2ou can e it a D/..&//3 4ith the 0(%! D/ statement.
See a!s"
#xam$!e
Dim A As Byte Do A = A + 1 Print A Loop Until A = 10 Print A 'start the loop 'increment A 'print it 'Repeat loop until A = 10 'A is still 10 here
FOR
Acti"n
NE1T
Syntax
Remarks
Var 'tart 0nd Value -ar . start. en0 . ste$ . !he variable counter to use !he starting value of the variable var !he ending value of the variable var !he value var is increased#decreased 4ith each time +0(! is encountered.
yte/ Integer/ ,"r0/ &"ng/ Sing!e1 yte/ Integer/ ,"r0/ &"ng/ Sing!e/ 2"nstant1 yte/ Integer/ ,"r0/ &"ng/ Sing!e/ 2"nstant1 yte/ Integer/ ,"r0/ &"ng/ Sing!e/ 2"nstant1
6or incremental loops you must use !/. 6or decremental loops you must use D/$+!/. 2ou may use !/ for a decremental loop but in that case you must use a negative '!03 : 6or a 7 10 !o 1 '!03 31 2ou must end a 6/) structure 4ith the +0(! statement. !he use of '!03 is optional. "y default a value of 1 is used.
See a!s"
)#X* / #XI* +%R
#xam$!e D45 Y A% B$&6 7 A A% B$&67; '% A$&6 $ ) 10 D5'E6 $ 10 D@* &84% 10 &456% D&84% *>6 '(%* D/#4>& &86 G'(=6% D>6;& ; 0"*=>& @*H>2 D>6;& ' 0"*=>& =/2 F*# A ) 1 T* 10 F*# 1 ) Y T* 1 P#4>& 1 F A N6;& N6;& D45 S A% S4>:(6 F*# S ) 1 T* + S&6/ 0 1 P#4>& S N6;& E>@
WAITMS
Acti"n
'uspends program e ecution for a given time in m'.
Syntax
,AI*MS m'
Remarks
m' !he number of milliseconds to 4ait. (1:;<<)
!he delay time is based on the used (:tal (fre=uency). !he use of interrupts can slo4 do4n this routine. !his statement is provided for the %;. statements. $hen you 4rite to an 003)/* you must 4ait for 10 m' after the 4rite instruction.
See a!s"
D0&A2 , $A%!
#xam$!e
SHIFT
Acti"n
'hifts all bits one place to the left or right.
Syntax
8 , shifts9
Remarks
Var 'hifts "yte, %nteger#$ord or &ong variable. !he number of shifts to perform.
!he '5%6! statements shifts all bits to the left or right and so for a byte after A shifts, the byte 4ill be Bero.
See a!s"
'5%6!%+ , '5%6!/C!
)/!A!0
#xam$!e
Dim a as $ord a 7 1;A '5%6! a, &06! , 1 3rint a -;<D
Syntax
WHILE condition statements WEND
Remarks
%f the condition is true then any intervening statements are e ecuted until the $0+D statement is encountered. "A'./* then returns to the $5%&0 statement and chec1s condition. %f it is still true, the process is repeated. %f it is not true, e ecution resumes 4ith the statement follo4ing the $0+D statement.
See a!s"
D/ .. &//3 , 6/) .. +0(!
#xam$!e
Dim A As yte ,hi!e A <= 10 'rint A Incr A ,en0