Translate

Membuat Alat Pendeteksi Suhu dan Kelembapan Menggunakan Dotmatrik dan DHT11

Membuat Alat Pendeteksi Suhu dan Kelembapan Menggunakan Dotmatrik dan DHT11


            Pada kesempatan yang berbahagia kali ini saya akan menjelaskan mengenai bagaimana cara mengakses dan membuat sebuah alat yang mana alat tersebut dapat mendeteksi suhu dan kelembapan serta ditampilkan kedalam dotmatrix 5x7, sensor yang dipakai yaitu DHT11 untuk detektor suhu dan kelembapan kemudian IC dotmatrix yang digunakan adalah 74HC595. Pada alat ini menggunakan mikrokontroller ATMega8 sebagai processornya. Jadi tampilan alat ini adalah suhu dan kelembapan, untuk lebih jelasnya berikut program dan skemanya.


a. Skematik Rangkaian





b. VIDEO HASILNYA





c. Program Bascom AVR

$regfile = "m8def.dat"
$crystal = 12000000

Declare Sub Get_th(t As Byte , H As Byte)
Config Serialin = Buffered , Size = 128
Config Serialout = Buffered , Size = 128

Dht_put Alias Portb.4
Dht_get Alias Pinb.4
Dht_io_set Alias Ddrb.4

Dim T As Byte
Dim H As Byte
Dim Tin As Byte
Dim Hin As Byte

Dim Satuant As Byte
Dim Satuanh As Byte
Dim Puluhant As Byte
Dim Puluhanh As Byte
Dim Strsatuant As String * 5
Dim Strsatuanh As String * 5
Dim Strpuluhant As String * 5
Dim Strpuluhanh As String * 5
Dim Awal1 As Integer
Dim Akhir1 As Integer
Dim Awal2 As Integer
Dim Akhir2 As Integer
Dim Awal3 As Integer
Dim Akhir3 As Integer
Dim Awal4 As Integer
Dim Akhir4 As Integer
Dim Awal5 As Integer
Dim Akhir5 As Integer
Dim Awal6 As Integer
Dim Akhir6 As Integer


Dim Crc As Byte
Dim Mybyte As Byte
Dim Sensor_data As String * 40
Dim Tmp_str8 As String * 8
Dim Count As Byte
Dim Coun As Integer

Enable Interrupts

Set Dht_io_set
Set Dht_put

Dataout Alias Portc.1
Clock Alias Portc.2

Dataout2 Alias Portb.3
Clock2 Alias Portb.5

Dim Datas As Byte
Dim Datasx As Byte

Dim I As Integer
Dim Zz As Integer


Ddrc = &B11111111
Ddrb.2 = 1
Ddrb.5 = 1

Main:

Awal1 = 0
Akhir1 = 0
Awal2 = 0
Akhir2 = 0
Awal3 = 0
Akhir3 = 0


Do

Wait 1
Call Get_th(t , H)

Tin = T Mod 100
Puluhant = Tin / 10
Satuant = Tin Mod 10


Hin = H Mod 100
Puluhanh = Hin / 10
Satuanh = Hin Mod 10

'satuan
Awal1 = Satuant * 8
Akhir1 = Awal1 + 7

'puluhan
Awal2 = Puluhant * 8
Akhir2 = Awal2 + 7

'T atau H
Awal3 = 0
Akhir3 = Awal3 + 7


'satuan
Awal4 = Satuanh * 8
Akhir4 = Awal4 + 7

'puluhan
Awal5 = Puluhanh * 8
Akhir5 = Awal5 + 7

'T atau H
Awal6 = 8
Akhir6 = Awal6 + 7


Goto Datakirim



Loop



Datakirim:
Coun = 0
Do

For I = Awal1 To Akhir1

Portc.2 = 0
Portc.2 = 1

Portb.5 = 0
Portb.5 = 1


Datasx = Lookup(i , Variasi)
Shiftout Dataout2 , Clock2 , Datasx , 1


Datas = Lookup(i , Kosong)
Shiftout Dataout , Clock , Datas , 1

Datas = Lookup(i , Kosong)
Shiftout Dataout , Clock , Datas , 1

Datas = Lookup(i , Angka)
Shiftout Dataout , Clock , Datas , 1


Portb.5 = 0
Portc.2 = 0

Waitus 100

Portc.0 = 1
Portc.0 = 0

Portb.2 = 1
Portb.2 = 0


Next I




For I = Awal2 To Akhir2

Portc.2 = 0
Portc.2 = 1

Portb.5 = 0
Portb.5 = 1


Datasx = Lookup(i , Variasi)
Shiftout Dataout2 , Clock2 , Datasx , 1


Datas = Lookup(i , Kosong)
Shiftout Dataout , Clock , Datas , 1

Datas = Lookup(i , Angka)
Shiftout Dataout , Clock , Datas , 1

Datas = Lookup(i , Kosong)
Shiftout Dataout , Clock , Datas , 1


Portb.5 = 0
Portc.2 = 0
Waitus 100

Portc.0 = 1
Portc.0 = 0

Portb.2 = 1
Portb.2 = 0


Next I



For I = Awal3 To Akhir3

Portc.2 = 0
Portc.2 = 1

Portb.5 = 0
Portb.5 = 1


Datasx = Lookup(i , Variasi)
Shiftout Dataout2 , Clock2 , Datasx , 1


Datas = Lookup(i , Huruf)
Shiftout Dataout , Clock , Datas , 1

Datas = Lookup(i , Kosong)
Shiftout Dataout , Clock , Datas , 1

Datas = Lookup(i , Kosong)
Shiftout Dataout , Clock , Datas , 1


Portb.5 = 0
Portc.2 = 0
Waitus 100

Portc.0 = 1
Portc.0 = 0

Portb.2 = 1
Portb.2 = 0

Next I

Incr Coun

Loop Until Coun = 1000

'===================================
Coun = 0
Do

For I = Awal4 To Akhir4

Portc.2 = 0
Portc.2 = 1

Portb.5 = 0
Portb.5 = 1


Datasx = Lookup(i , Variasi)
Shiftout Dataout2 , Clock2 , Datasx , 1


Datas = Lookup(i , Kosong)
Shiftout Dataout , Clock , Datas , 1

Datas = Lookup(i , Kosong)
Shiftout Dataout , Clock , Datas , 1

Datas = Lookup(i , Angka)
Shiftout Dataout , Clock , Datas , 1


Portb.5 = 0
Portc.2 = 0

Waitus 100

Portc.0 = 1
Portc.0 = 0

Portb.2 = 1
Portb.2 = 0


Next I




For I = Awal5 To Akhir5

Portc.2 = 0
Portc.2 = 1

Portb.5 = 0
Portb.5 = 1


Datasx = Lookup(i , Variasi)
Shiftout Dataout2 , Clock2 , Datasx , 1


Datas = Lookup(i , Kosong)
Shiftout Dataout , Clock , Datas , 1

Datas = Lookup(i , Angka)
Shiftout Dataout , Clock , Datas , 1

Datas = Lookup(i , Kosong)
Shiftout Dataout , Clock , Datas , 1


Portb.5 = 0
Portc.2 = 0
Waitus 100

Portc.0 = 1
Portc.0 = 0

Portb.2 = 1
Portb.2 = 0


Next I



For I = Awal6 To Akhir6

Portc.2 = 0
Portc.2 = 1

Portb.5 = 0
Portb.5 = 1


Datasx = Lookup(i , Variasi)
Shiftout Dataout2 , Clock2 , Datasx , 1


Datas = Lookup(i , Huruf)
Shiftout Dataout , Clock , Datas , 1

Datas = Lookup(i , Kosong)
Shiftout Dataout , Clock , Datas , 1

Datas = Lookup(i , Kosong)
Shiftout Dataout , Clock , Datas , 1


Portb.5 = 0
Portc.2 = 0
Waitus 100

Portc.0 = 1
Portc.0 = 0

Portb.2 = 1
Portb.2 = 0

Next I

Incr Coun

Loop Until Coun = 1000


Goto Main
Return



Sub Get_th(t As Byte , H As Byte)

 Count = 0
 Sensor_data = ""
 Set Dht_io_set
 Reset Dht_put
 Waitms 25

 Set Dht_put
 Waitus 40
 Reset Dht_io_set
 Waitus 40
 If Dht_get = 1 Then
    H = 1
    Exit Sub
 End If

  Waitus 80
  If Dht_get = 0 Then
    H = 2
    Exit Sub
  End If

  While Dht_get = 1 : Wend

   Do
    While Dht_get = 0 : Wend
    Waitus 30
     If Dht_get = 1 Then
       Sensor_data = Sensor_data + "1"
       While Dht_get = 1 : Wend
       Else
       Sensor_data = Sensor_data + "0"
    End If
    Incr Count
   Loop Until Count = 40

   Set Dht_io_set
   Set Dht_put

   Tmp_str8 = Left(sensor_data , 8)
   H = Binval(tmp_str8)

   Tmp_str8 = Mid(sensor_data , 17 , 8)
   T = Binval(tmp_str8)

   Tmp_str8 = Right(sensor_data , 8)
   Crc = Binval(tmp_str8)

   Mybyte = T + H
   If Mybyte <> Crc Then
      H = 3
   End If
End Sub
Return


Kosong:
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111

Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111

Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111

Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111

Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111

Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111

Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111

Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111

Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111

Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111
Data &B11111111




Variasi:
Data &B1000000
Data &B0100000
Data &B0010000
Data &B0001000
Data &B0000100
Data &B0000010
Data &B0000001
Data &B0000001

Data &B1000000
Data &B0100000
Data &B0010000
Data &B0001000
Data &B0000100
Data &B0000010
Data &B0000001
Data &B0000001

Data &B1000000
Data &B0100000
Data &B0010000
Data &B0001000
Data &B0000100
Data &B0000010
Data &B0000001
Data &B0000001

Data &B1000000
Data &B0100000
Data &B0010000
Data &B0001000
Data &B0000100
Data &B0000010
Data &B0000001
Data &B0000001

Data &B1000000
Data &B0100000
Data &B0010000
Data &B0001000
Data &B0000100
Data &B0000010
Data &B0000001
Data &B0000001

Data &B1000000
Data &B0100000
Data &B0010000
Data &B0001000
Data &B0000100
Data &B0000010
Data &B0000001
Data &B0000001

Data &B1000000
Data &B0100000
Data &B0010000
Data &B0001000
Data &B0000100
Data &B0000010
Data &B0000001
Data &B0000001

Data &B1000000
Data &B0100000
Data &B0010000
Data &B0001000
Data &B0000100
Data &B0000010
Data &B0000001
Data &B0000001

Data &B1000000
Data &B0100000
Data &B0010000
Data &B0001000
Data &B0000100
Data &B0000010
Data &B0000001
Data &B0000001

Data &B1000000
Data &B0100000
Data &B0010000
Data &B0001000
Data &B0000100
Data &B0000010
Data &B0000001
Data &B0000001


'(

Aa:
Data &B11000111
Data &B00111001
Data &B00111001
Data &B00000001
Data &B00000001
Data &B00111001
Data &B00111001
Data &B00111001



Bb:
Data &B00000001
Data &B00111101
Data &B00111101
Data &B00000011
Data &B00000001
Data &B00111101
Data &B00111001
Data &B00000011

')
'0-7
Angka:
'0:
Data &B10000001
Data &B10011001
Data &B10011001
Data &B10011001
Data &B10011001
Data &B10011001
Data &B10011001
Data &B10000001


'8-15
'1:
Data &B11000111
Data &B10000111
Data &B11100111
Data &B11100111
Data &B11100111
Data &B11100111
Data &B11100111
Data &B10000001


'16-23
'2:
Data &B11000001
Data &B10011001
Data &B11111001
Data &B11110011
Data &B11100111
Data &B11001111
Data &B10011111
Data &B10000001


'24 31
'3:
Data &B10000001
Data &B11111001
Data &B11111001
Data &B11000001
Data &B11000001
Data &B11111001
Data &B11111001
Data &B10000001


'32-39
'4:
Data &B10011001
Data &B10011001
Data &B10011001
Data &B10000001
Data &B10000001
Data &B11111001
Data &B11111001
Data &B11111001


'40-47
'5:
Data &B10000001
Data &B10011111
Data &B10011111
Data &B10000001
Data &B10000001
Data &B11111001
Data &B11111001
Data &B10000001



'48-55
'6:
Data &B10000001
Data &B10011111
Data &B10011111
Data &B10000001
Data &B10011001
Data &B10011001
Data &B10011001
Data &B10000001


'56-63
'7:
Data &B10000001
Data &B10000001
Data &B11111001
Data &B11110011
Data &B11100111
Data &B11001111
Data &B10011111
Data &B10011111


'64-71
'8:
Data &B10000001
Data &B10011001
Data &B10011001
Data &B10000001
Data &B10011001
Data &B10011001
Data &B10011001
Data &B10000001


'72-79
'9:
Data &B10000001
Data &B10011001
Data &B10011001
Data &B10011001
Data &B10000001
Data &B11111001
Data &B11111001
Data &B10000001


Huruf:
'80-87
'10:
Data &B11110001
Data &B11110111
Data &B11110001
Data &B11111101
Data &B11110001
Data &B11111111
Data &B11111111
Data &B11111111


'88-95
'11:
Data &B11110101
Data &B11110101
Data &B11110001
Data &B11110101
Data &B11110101
Data &B11111111
Data &B11111111
Data &B11111111













No comments:

Post a Comment