Anda di halaman 1dari 4

$regfile = "m32def.

dat"

$crystal = 11059200

Config Lcdpin = Pin , Db4 = Portd.4 , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7 , E = Portd.3 , Rs =
Portd.2

Config Portb = Input

Portb = &HFF

Config Lcd = 16 * 2

Config Adc = Single , Prescaler = Auto , Reference = Avcc

Config Portc = Output

Dim Hsl As Integer

Dim Mv As Single , Tm As Single

Dim I As Byte , Ptr As Byte

Dim S As Byte

Const Dly = 5

Start Adc

Cls

Cursor Off
S=0

Do

Hsl = Getadc(0)

Mv = Hsl * 5000

Mv = Mv / 1023

Tm = Mv / 10

Upperline

Lcd "Temp:" ; Tm

If Tm >= 0 And Tm < 40 Then

Lowerline

Lcd "KATUB MEMBUKA"

If S = 1 Then

Gosub Tutup

S=0

End If

End If

If Tm >= 41 Then

Lowerline

Lcd "KATUB MENUTUP"


If S = 0 Then

Gosub Buka

S=1

End If

End If

Loop

End

Buka:

Ptr = 13

For I = 1 To Ptr

Portc = &H80

Waitms Dly

Portc = &H40

Waitms Dly

Portc = &H20

Waitms Dly

Portc = &H10

Waitms Dly

Next I

Return
Tutup:

Ptr = 13

For I = 1 To Ptr

Portc = &H10

Waitms Dly

Portc = &H20

Waitms Dly

Portc = &H40

Waitms Dly

Portc = &H80

Waitms Dly

Next I

Return

Anda mungkin juga menyukai