Membuat Simulasi Inkubator/Pengatur Suhu Proteus+CodeVision Avr

Membuat Simulasi Inkubator/Pengatur Suhu Proteus+BASCOM Avr LM35 ATMEGA8535

Alat dan Bahan :

- Software Proteus
- Software Bascom AVR



Screenshot

Membuat Simulasi Inkubator/Pengatur Suhu Proteus+CodeVision Avr



Membuat Simulasi Inkubator/Pengatur Suhu Proteus+CodeVision Avr


Alat Di proteus

Alat Di proteus



CODE di BASCOM :

$regfile = "m8535.dat"
$crystal = 8000000
$baud = 9600

Config Lcdpin = Pin , Rs = Portb.0 , E = Portb.1 , Db4 = Portb.4 ,
Config Lcdpin = Pin , Db5 = Portb.5 , Db6 = Portb.6 , Db7 = Portb.7
Config Lcd = 16 * 2

Config Porta.1 = Output
Config Porta.2 = Output
Config Porta.3 = Output
Config Porta.4 = Output
Config Porta.5 = Output
Config Porta.6 = Output
Config Porta.7 = Output

Config Portd = Output
Config Timer1 = Pwm , Pwm = 8 , Compare_a_pwm = Clear_up , Prescale = 1
Dim Nilai As Integer
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Dim Data_mentah As Integer
Dim Hasil As Single
Dim Suhuasli As Integer
Dim Y As String * 3
Dim Selisih As Integer
Dim Ref As Integer
Start Adc

Portd.2 = 1


Cls
Cursor Off

Locate 1 , 1
Lcd "Suhu Ref.: "
Locate 2 , 1
Lcd "Suhu : "

Ddrc = &B11110000
Portc = &B11111111

Do

Data_mentah = Getadc(0)
Hasil = 0.49 * Data_mentah
Nilai = Hasil * 2.55
Suhuasli = Hasil



Portc = &B11101111
If Pinc.0 = 0 Then
Y = Y + "1"
Elseif Pinc.1 = 0 Then
Y = Y + "4"
Elseif Pinc.2 = 0 Then
Y = Y + "7"
Elseif Pinc.3 = 0 Then
Y = "0"                                                     '
End If
Waitms 80

Portc = &B11011111
If Pinc.0 = 0 Then
Y = Y + "2"
Elseif Pinc.1 = 0 Then
Y = Y + "5"
Elseif Pinc.2 = 0 Then
Y = Y + "8"
Elseif Pinc.3 = 0 Then
Y = Y + "0"
End If
Waitms 80

Portc = &B10111111
If Pinc.0 = 0 Then
Y = Y + "3"
Elseif Pinc.1 = 0 Then
Y = Y + "6"
Elseif Pinc.2 = 0 Then
Y = Y + "9"
Elseif Pinc.3 = 0 Then
Y = Y + "#"
End If
Waitms 80



Locate 1 , 12
Lcd Y
Print Y



'Dianggap Batas Suhu = 50
'225 kecepatan motor
'255/50=5.1  'simulasi 51 biar cpt

Ref = Val(y)
Selisih = Suhuasli - Ref


If Suhuasli > Ref And Ref > 0 Then
Pwm1a = Selisih * 5
Elseif Suhuasli = Ref Then
Pwm1a = 0
Elseif Suhuasli < Ref Then
Pwm1a = 0
End If

Locate 1 , 15
Lcd "C"
Locate 2 , 8
Lcd Suhuasli ; " C"


If Suhuasli > 20 And Suhuasli < 23 Then
Porta.1 = 1
Porta.2 = 0
Porta.3 = 0
Porta.4 = 0
Porta.5 = 0
Porta.6 = 0
Porta.7 = 0
Elseif Suhuasli > 23 And Suhuasli < 26 Then
Porta.1 = 1
Porta.2 = 1
Porta.3 = 0
Porta.4 = 0
Porta.5 = 0
Porta.6 = 0
Porta.7 = 0
Elseif Suhuasli > 26 And Suhuasli < 29 Then
Porta.1 = 1
Porta.2 = 1
Porta.3 = 1
Porta.4 = 0
Porta.5 = 0
Porta.6 = 0
Porta.7 = 0
Elseif Suhuasli > 32 And Suhuasli < 35 Then
Porta.1 = 1
Porta.2 = 1
Porta.3 = 1
Porta.4 = 1
Porta.5 = 0
Porta.6 = 0
Porta.7 = 0
Elseif Suhuasli > 38 And Suhuasli < 41 Then
Porta.1 = 1
Porta.2 = 1
Porta.3 = 1
Porta.4 = 1
Porta.5 = 1
Porta.6 = 0
Porta.7 = 0
Elseif Suhuasli > 44 And Suhuasli < 47 Then
Porta.1 = 1
Porta.2 = 1
Porta.3 = 1
Porta.4 = 1
Porta.5 = 1
Porta.6 = 1
Porta.7 = 0
Elseif Suhuasli > 50 Then
Porta.1 = 1
Porta.2 = 1
Porta.3 = 1
Porta.4 = 1
Porta.5 = 1
Porta.6 = 1
Porta.7 = 1
End If

Loop
End

Comments

Popular posts from this blog

Cara Memperbaiki error 0xc00007b “the application was unable to start correctly”

Cara Memperbaiki Black Screen Di Windows 10

Kumpulan Template Login Hotspot Mikrotik Keren