Minggu, 22 September 2013

Contoh Program suhu Dengan Bascome AVR


$regfile = "m16def.dat" 'inisialisasi mk yang digunakan atmega 16
$crystal = 11059200 'inisialisasi xtal yang digunakan 11059200 hz
Config Lcdpin = Pin , Rs = Portb.0 , E = Portb.2 , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7
Config Lcd = 16 * 2
Cursor Off 'matikan kursor
Dim Suhu As Single
Dim Adc1 As Word
Dim Outsuhu As Single
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Start Adc
Enable Interrupts
Config Portc = Output
Portc = 255
Cls
Do
Adc1 = Getadc(0)
Suhu = Adc1 / 1023
Suhu = Suhu * 5
Suhu = Suhu * 100
Outsuhu = Suhu
'Outsuhu = Fusing(suhu , "#.##")
Upperline
Lcd Fusing(suhu , "#.##")
Waitms 100

If Suhu => 22 And Suhu < 30 Then
Portc = &B00110011
Elseif Suhu => 30 And Suhu < 100 Then
Portc = &B00000000
Else
Portc = &B10101010
End If

Loop

0 komentar:

Posting Komentar