Ceriwis  

Go Back   Ceriwis > HOBI > Komputer & Teknologi > Programming

Programming Share, tanya jawab, saling bantu antar programmer dengan berbagai macam bahasa pemrograman.

Reply
 
Thread Tools
  #1  
Old 11th November 2011
Braincode's Avatar
Braincode Braincode is offline
Ceriwis Addicted
 
Join Date: Nov 2011
Posts: 4,638
Rep Power: 20
Braincode mempunyai hidup yang Normal
Default baca sht75 pake basic

salam kenal

pagi gan ada yang bisa bantu baca sensor sht75 ke lcd g gan pake bahasa basic?

mohon bimbinganya soalnya msh baru gan

rencana mau ngukur suhu ma klembaban trus ditampilin ke lcd

gw pake atmega8535 kalo ada tlong kirim ke [email protected].

terima kasih



ini coding saya tp msh eror.tlong di jlasin kaslahne





$regfile = "m8535.dat"

$crystal = 80000000







Config Lcdpin = Pinb , Db4 = Port.4 , Db5 = Port.5 , Db6 = Port.6 , Db7 = Port.7 , E = Portb.1 , Rs = Portb.3 , Rw = Portb.2



Config Lcd = 16 * 2



Dim Ctr As Byte

Dim Dataword As Word

Dim Command As Byte

Dim Dis As String * 20



Dim Calc As Single

Dim Calc2 As Single

Dim Rhlinear As Single

Dim Rhlintemp As Single

Dim Tempc As Single

Dim Tempf As Single





Dim C As Integer

Dim Pul As Integer , Sat As Integer , Kom As Integer

Dim Tpul As Integer , Tsat As Integer , Tkom As Integer

Dim Hpul As Integer , Hsat As Integer , Hkom As Integer

Dim Vt As Single , Vpul As Single , Vkom As Single

Dim Svtemp As Single , Svhumi As Single

Dim Svt As Eram Single

Dim Svh As Eram Single





Const C1 = -4

Const C2 = 0.0405

Const C3 = -0.0000028

Const T1c = 0.01

Const T2 = 0.00008

Const T1f = 0.018



Sck Alias Portb.1

Dataout Alias Portb.0

Datain Alias Pinb.0



Declare Sub Getit()

Declare Sub Getsv()



Ddrb = &B11111111 "port.b sebagai output"

Config Pinb.0 = Output

Config Pinb.1 = Output



Ddrd = &B11110000 "lsb sebagai input msb sebagai output"

Portd = &B00001111 "nilai portd adalah 00001111"



C = 0

Tpul = 0

Tsat = 0

Tkom = 0

Hpul = 0

Hsat = 0

Hkom = 0

Vpul = 0

Vkom = 0

Vt = 0





Set Dataout

For Ctr = 1 To 12

Set Sck

Waitus 2

Reset Sck

Waitus 2

Next Ctr



Do

Cls

Cursor Off

Command = &B00000011 "command untuk membaca temperatur"

Call Getit



Tempf = T1f * Dataword

Tempf = Tempf - 40



Tempc = T1c * Dataword

Tempc = Tempc - 40



Dis = Fusing(tempc , "##.##")

Locate 1 , 1

Lcd Dis ; "C "



Command = &B00000101 "command untuk membaca humidity"

Call Getit



'menghitung Rh linier

Calc = C2 * Dataword

Calc2 = Dataword * Dataword

Calc2 = C3 * Calc2

Calc = Calc + C1

Rhlinear = Calc + Calc2



'menghitung kompensasi suhu pada Rh linier

Calc = T2 * Dataword

Calc2 = Calc + T1c

Calc2 = Tempc - 25

Calc = Calc2 * Calc

Rhlintemp = Calc + Rhlinear





Dis = Fusing(rhlintemp , "##.##")

Locate 1 , 9

Lcd Dis ; " Rh"



Dis = Fusing(tempc , "##.##")

Locate 2 , 1

Lcd Dis ; " C"



Dis = Fusing(svhumi , "##.##")

Locate 2 , 9

Lcd Dis ; " Rh"

Waitms 500

Loop



'proses pembacaan Sensor sht11

Sub Getit()



Local Datavalue As Word

Local Databyte As Byte

'mulai yuk "transmission start"

Set Sck

Reset Dataout

Reset Sck

Set Sck

Set Dataout

Reset Sck

'Send Command

Shiftout Dataout , Sck , Command , 1



Ddrb = &B11111110 'set datain sebagai input

Config Pinb.0 = Input

Set Sck 'ACK

Reset Sck

Waitus 10

Bitwait Pinb.0 , Reset 'tunggusampai sht mereset datain

Shiftin Datain , Sck , Databyte , 1 'get MSB

Datavalue = Databyte



Ddrb = &B11111111

Config Pinb.0 = Output



Reset Dataout

Set Sck

Reset Sck



Ddrb = &B11111110 ' set datain sebagai input

Config Pinb.0 = Input



Shiftin Datain , Sck , Databyte , 1

Shift Datavalue , Left , 8 'get LSB

Datavalue = Datavalue Or Databyte



Dataword = Datavalue



Ddrb = &B11111111

Config Pinb.0 = Output



Reset Dataout

Set Sck

Reset Sck



Ddrb = &B11111110 "set datain sebagai input"

Config Pinb.0 = Input



Shiftin Datain , Sck , Databyte , 1 'CRC tidak digunakan



Ddrb = &B11111111

Config Pinb.0 = Output



Set Dataout

Set Sck

Reset Sck

End Sub

End



Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


 


All times are GMT +7. The time now is 06:19 AM.


no new posts