LISTING PROGRAM LENGKAP PENGIRIM
$prog &HFF , &HC4 , &H99 , &H00 ' generated. Take care that the chip supports all fuse bytes.
$regfile = "m32def.dat"
$crystal = 8000000
$hwstack = 40
$swstack = 16
$framesize = 32 $baud = 9600
Dim S As String * 20
Dim Z1 As String * 20 , Z2 As String * 20
Dim Sw1 As Word , Sw2 As Word , Sw3 As Word , Sw0 As Word
Dim V_sw1 As Word , V_sw2 As Word , V_sw3 As Word , V_sw0 As Word
Dim L_an As Word , K_an As Word , Pot As Word
Dim Vl_sw As Word , Vk_sw As Word , Vtm As Long
Config Portd = Output
Config Serialin = Buffered , Size = 40
Config Lcd = 20 * 4
Config Lcdpin = Pin , Db4 = Portb.3 , Db5 = Portb.2 , Db6 = Portb.1 , Db7 = Portb.0 , E = Portb.4 , Rs = Portb.5
Config Adc = Single , Prescaler = Auto
Deflcdchar 0 , 24 , 24 , 32 , 32 , 32 , 32 , 32 , 32
Deflcdchar 1 , 32 , 6 , 9 , 8 , 8 , 9 , 6 , 32
Enable Interrupts
Cursor Off Cls
' Print "D_" ; Pot ; " "
'---
Locate 1 , 1 : Lcd "Suhu:" ; Z1 ; Chr(1) ; Chr(0) ; " "
Locate 3 , 10 : Lcd "Stl:M"
Locate 2 , 1 : Lcd "Sp1:0"
Locate 4 , 1 : Lcd "V:"
Locate 3 , 1 : Lcd "Vl:0"
Portd.2 = 1
Waitms 400
Do
Start Adc
Sw0 = Getadc(3)
Sw1 = Getadc(2)
Sw2 = Getadc(1)
Sw3 = Getadc(0)
K_an = Getadc(4) L_an = Getadc(5)
Pot = Getadc(6)
Pot = Pot / 2
'If Pot >= 100 Then
'Pot = 100 'End If
'==================================================== Auto / Manual Kipas =====
'--- auto --- If K_an >= 500 And Vk_sw = 0 Then
Vk_sw = 1
Locate 2 , 10 : Lcd "Stk:A" ;
Waitms 1000
K_an = 0
Print "A" End If
'--- --- Manual --
Vk_sw = 0
Locate 2 , 10 : Lcd "Stk:M" ;
Waitms 1000
K_an = 0 Print "B"
End If
'==================================================== Auto / Manual Lampu =====
'--- auto ---
If L_an >= 500 And Vl_sw = 0 Then Vl_sw = 1
Locate 3 , 10 : Lcd "Stl:A" ;
Waitms 1000
L_an = 0
Print "C" End If
'--- --- Manual --
If L_an >= 500 And Vl_sw = 1 Then
Vl_sw = 0
Locate 3 , 10 : Lcd "Stl:M" ; Waitms 1000
L_an = 0
Print "D"
End If
'=================================== Control kupas manual ======================
'--- Speed 0 ---
If Sw0 >= 500 Then
Locate 2 , 1 : Lcd "Sp:0 "
Print "K0"
Waitms 1000
End If
'--- Speed 1 ---
If Sw1 >= 500 Then
Print "K1"
Locate 2 , 1 : Lcd "Sp:1 "
Waitms 1000
Sw0 = 0
End If
'--- speed 2 --- If Sw2 >= 500 Then
Locate 2 , 1 : Lcd "Sp:2 "
Print "K2"
Waitms 1000 Sw0 = 0
End If
'--- speed 3 ---
If Sw3 >= 500 Then
Locate 2 , 1 : Lcd "Sp:3 " ; Print "K3"
Waitms 1000
Sw0 = 0
End If
'---
'==================================================================== ==========
'=================================== Control lampu manual ======================
'--- lampu 0 --- If Pot <= 102 And Pot >= 0 And Vl_sw = 0 Then
Print "L0"
Waitms 100
End If
'--- lampu 1 --- If Pot <= 204 And Pot > 102 And Vl_sw = 0 Then
Print "L1"
Locate 3 , 1 : Lcd "Vl:L1"
Waitms 100
End If
'--- lampu 2 ---
If Pot <= 306 And Pot > 204 And Vl_sw = 0 Then
Print "L2"
Locate 3 , 1 : Lcd "Vl:L2"
Waitms 100
End If
'--- lampu 3 ---
If Pot <= 408 And Pot > 306 And Vl_sw = 0 Then
Print "L3"
Locate 3 , 1 : Lcd "Vl:L3"
Waitms 100
End If
'--- lampu 4 --- If Pot <= 511 And Pot > 408 And Vl_sw = 0 Then
Print "L4"
Locate 3 , 1 : Lcd "Vl:L4"
Waitms 100
End If
'==================================================================== ==========
Input S Noecho
Z1 = Mid(s , 3 , 4)
Z2 = Mid(s , 8 , 4)
Locate 1 , 1 : Lcd "S:" ; Z1 ; Chr(1) ; Chr(0) ; " " Locate 1 , 10 : Lcd "L:" ; Z2 ; " "
Locate 4 , 1 : Lcd "V:" ; Pot ; " "
Loop
PENERIMA
$prog &HFF , &HC4 , &H99 , &H00 '
$regfile = "m16def.dat"
$crystal = 8000000
$hwstack = 40 $swstack = 16
$framesize = 32
$baud = 9600
'===================================================================
Dim Z1 As String * 20 , Z2 As String * 20
Dim C As Integer , S As Word
'==================================================================
Dim Lm35 As Word , Sen_35 As Single , Suhu_35 As String * 20 Dim Psen As Word , Sen_pho As Word
'==================================================================
Config Input1 = Cr , Echo = Crlf
Config Serialin = Buffered , Size = 40
Config Lcd = 40 * 2
Config Lcdpin = Pin , Db4 = Portb.3 , Db5 = Portb.2 , Db6 = Portb.1 , Db7 = Portb.0 , E = Portb.4 , Rs = Portb.5
Config Adc = Single , Prescaler = Auto
Config Portb = Output
Config Portd.2 = Output
Config Portd.3 = Output Config Portd.4 = Output
Config Portd.5 = Output
Config Portd.6 = Output
Config Portd.7 = Output
Config Portc = Output
'---
Lampu1 Alias Portd.3
Lampu2 Alias Portd.4
Lampu3 Alias Portd.5
Lampu4 Alias Portd.6 Lampu5 Alias Portd.7
Lampu6 Alias Portc.0
Lampu7 Alias Portc.1
Lampu8 Alias Portc.7
'--- Enable Interrupts
Cursor Off
Cls
Locate 2 , 10 : Lcd "test " Main:
Do
Start Adc
Lm35 = Getadc(0)
Psen = Getadc(1)
Lm35 = Lm35 * 5
Sen_35 = Lm35 / 12
Suhu_35 = Fusing(sen_35 , "#.#")
Locate 1 , 1 : Lcd "IN:" ; Z1 ; ":" ; Suhu_35 ; ":" ; Sen_pho ; " " Print " " ; Suhu_35 ; ":" ; Sen_pho ; " "
Waitms 100
'=========================Z1========================================= =============
S = Ischarwaiting() If S = 1 Then
S = Waitkey()
End If
Z1 = Mid(s , 1 , 3)
'==================================================================== =========
'---
If Z1 = "K" Then
Goto Ch_kipas
End If
'---
If Z1 = "L" Then
Goto Ch_lampu
End If
'---
If Z1 = "A" Then Goto Main
End If
'---
If Z1 = "B" Then Goto Main
End If
'---
Return
'==================================================================== ===========
Ch_kipas:
'---
Do
Start Adc
Lm35 = Getadc(0) Psen = Getadc(1)
Psen = Psen * 5
Sen_pho = Psen / 10
Lm35 = Lm35 * 5 Sen_35 = Lm35 / 12
Suhu_35 = Fusing(sen_35 , "#.#")
Locate 1 , 1 : Lcd "IN:" ; Z1 ; ":" ; Suhu_35 ; ":" ; Sen_pho ; " "
S = Ischarwaiting() If S = 1 Then
S = Waitkey()
End If
Z1 = Mid(s , 1 , 3)
'==================================================================== ===========
If Z1 = "K" Then
Goto Ch_kipas
End If
'==================================================================== ===========
If Z1 = "L" Then
Goto Ch_lampu
'==================================================================== ===========
If Z1 = "0" Then
Servo(1) = 0
End If
'==================================================================== ==========
If Z1 = "1" Then
Servo(1) = 5 End If
'==================================================================== ==========
If Z1 = "2" Then
Servo(1) = 20
End If
'==================================================================== ==========
If Z1 = "3" Then
Servo(1) = 80
End If
'==================================================================== ==========
Print "K" ; Suhu_35 ; ":" ; Sen_pho ; " "
Waitms 100
'---
Loop Return
'==================================================================== ===========
Ch_lampu:
'--- Do
Start Adc
Lm35 = Getadc(0)
Psen = Getadc(1)
Sen_pho = Psen / 10
Lm35 = Lm35 * 5
Sen_35 = Lm35 / 12
Suhu_35 = Fusing(sen_35 , "#.#")
Locate 1 , 1 : Lcd "IN:" ; Z1 ; ":" ; Suhu_35 ; ":" ; Sen_pho ; " "
'==================================
S = Ischarwaiting()
If S = 1 Then S = Waitkey()
End If
Z1 = Mid(s , 1 , 3)
'==================================================================== ===========
If Z1 = "K" Then
Goto Ch_kipas
End If
'==================================================================== ===========
If Z1 = "L" Then
Goto Ch_lampu
End If
'==================================================================== ===========
If Z1 = "0" Then
Lampu1 = 0
Lampu2 = 0
Lampu3 = 0 Lampu4 = 0
Lampu5 = 0
Lampu6 = 0
Lampu8 = 0
End If
'==================================================================== ==========
If Z1 = "1" Then Lampu1 = 1
Lampu2 = 0
Lampu3 = 0
Lampu4 = 0
Lampu5 = 0 Lampu6 = 0
Lampu7 = 0
Lampu8 = 0
End If
'==================================================================== ==========
If Z1 = "2" Then
Lampu1 = 0
Lampu2 = 1
Lampu3 = 0 Lampu4 = 0
Lampu5 = 0
Lampu6 = 0
Lampu7 = 0
Lampu8 = 0
End If
'==================================================================== ==========
If Z1 = "3" Then
Lampu1 = 0
Lampu2 = 0 Lampu3 = 1
Lampu4 = 0
Lampu5 = 0
Lampu7 = 0
Lampu8 = 0
End If
'==================================================================== ==========
If Z1 = "4" Then
Lampu1 = 0
Lampu2 = 0
Lampu3 = 0 Lampu4 = 1
Lampu5 = 0
Lampu6 = 0
Lampu7 = 0
Lampu8 = 0 End If
'==================================================================== ==========
Print "L" ; Suhu_35 ; ":" ; Sen_pho ; " " Waitms 100
Loop