Read more
untuk mengganti jenis mikrokontroller avr yang dipergukan silakan ganti kode
$regfile = "m32def.dat"
lanjut....
ini adalah kode yang dipergunakan untuk membaca ADC secara free running pada pin adc mikrokontroller avr 40 pin .. dlam hal ini menggunakan mikrokontroller at mega 32
$regfile = "m32def.dat"
lanjut....
ini adalah kode yang dipergunakan untuk membaca ADC secara free running pada pin adc mikrokontroller avr 40 pin .. dlam hal ini menggunakan mikrokontroller at mega 32
$regfile = "m32def.dat"
$crystal = 12000000
Deflcdchar 0 , 28 , 20 , 28 , 32 , 32 , 32 , 32 , 32 ' replace 0 with number (0-7)
Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.2 , Db4 = Portc.4
Config Lcdpin = Pin , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7
Config Lcd = 16 * 2
Cursor Off
Cls
'Dim Pwm As Integer
Dim Pwm_eprom As Eram Integer
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Prescale = 1
Config Adc = Free , Prescaler = Auto , Reference = Avcc
Dim Suhuinadc As Word , Suhu1 As Word , Suhu12 As Word
Dim I As Word , Jml As Word , Rata2 As Word
Cls
Do
Start Adc
Suhuinadc = Getadc(0)
Suhu1 = Suhuinadc * 500
Suhu12 = Suhu1 / 1023
Jml = Jml + Suhu12
I = I + 1
If I = 20 Then
Rata2 = Jml / I
Cls
Locate 1 , 2
Lcd "suhu " ; Rata2
Locate 1 , 10
Lcd "suhu " ; Rata2
Waitms 100
End If
Loop
$crystal = 12000000
Deflcdchar 0 , 28 , 20 , 28 , 32 , 32 , 32 , 32 , 32 ' replace 0 with number (0-7)
Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.2 , Db4 = Portc.4
Config Lcdpin = Pin , Db5 = Portc.5 , Db6 = Portc.6 , Db7 = Portc.7
Config Lcd = 16 * 2
Cursor Off
Cls
'Dim Pwm As Integer
Dim Pwm_eprom As Eram Integer
Config Timer1 = Pwm , Pwm = 10 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Prescale = 1
Config Adc = Free , Prescaler = Auto , Reference = Avcc
Dim Suhuinadc As Word , Suhu1 As Word , Suhu12 As Word
Dim I As Word , Jml As Word , Rata2 As Word
Cls
Do
Start Adc
Suhuinadc = Getadc(0)
Suhu1 = Suhuinadc * 500
Suhu12 = Suhu1 / 1023
Jml = Jml + Suhu12
I = I + 1
If I = 20 Then
Rata2 = Jml / I
Cls
Locate 1 , 2
Lcd "suhu " ; Rata2
Locate 1 , 10
Lcd "suhu " ; Rata2
Waitms 100
End If
Loop
hasil pembacaaan data ADC , sebenarnya lebih tepat jika di sebut untuk membaca sensor suhu... karena memang kenyataanya source code bascom di atas dipergunakan untuk membaca data sensor suhu lalu ditampilkan ke LCD
selamat mencoba



0 Reviews
Silakan dikomentari