Download - dehidrator

Transcript

'****Dehidratoe PIC 16F628 2X16 LCD DHT11****Define SIMULATION_WAITMS_VALUE = 1TRISA = %00111111 'port a je izlazPORTA = 0TRISB = %00000000 'port b je izlazPORTB = 0AllDigitalDefine LCD_LINES = 2Define LCD_CHARS = 16Define LCD_BITS = 4Define LCD_DREG = PORTBDefine LCD_DBIT = 0Define LCD_RSREG = PORTBDefine LCD_RSBIT = 4Define LCD_EREG = PORTBDefine LCD_EBIT = 5Define LCD_COMMANDUS = 5000Define LCD_DATAUS = 100Define LCD_INITMS = 500Define 1WIRE_REG = PORTBDefine 1WIRE_BIT = 6Symbol grijac = PORTA.6Symbol ventilator = PORTA.5Dim podatak As ByteDim templ As ByteDim temph As ByteDim temperatura As WordDim v As BitDim a As ByteDim b As ByteDim humh As ByteDim huml As ByteDim sum As ByteDim dht11data As LongLcdinitLcddefchar 0, %01110, %01010, %01110, %00000, %00000, %00000, %00000, %00000 'degree symbolLcdcmdout LcdClearLcdout " DEHIDRATOR HRANE "Gosub showdht11End showdht11:init:a = 0b = 0TRISB.6 = 0PORTB.6 = 1WaitMs 2000PORTB.6 = 0WaitMs 20TRISB.6 = 1WaitUs 5dht11response:While PORTB.6 'cekam nulua = a + 1If a = 255 Then Goto errWenda = 0WaitUs 5e:a = a + 1If a = 255 Then Goto err 'cekam 1If PORTB.6 = 0 Then Goto eWaitUs 3a = 0While PORTB.6a = a + 1If a = 255 Then Goto errWenda = 0WaitUs 5For b = 0 To 39data:If a = 255 Then Goto errIf PORTB.6 = 0 Then Goto datadht11data = ShiftLeft(dht11data, 1)WaitUs 8If PORTB.6 = 1 Then podatak = 1 Else podatak = 0dht11data = dht11data + podataka = 0While PORTB.6a = a + 1If a = 255 Then Goto errWenda = 0Next bFor b = 0 to7kontrolnibit:If a = 255 Then Goto errIf PORTB.6 = 0 Then Goto kontrolnibitsum = ShiftLeft(sum, 1)WaitUs 8If PORTB.6 = 1 Then podatak = 1 Else podatak = 0sum = sum + podataka = 0While PORTB.6a = a + 1If a = 255 Then Goto errWenda = 0Next bhumh = dht11data.LBhuml = dht11data.HBtemph = dht11data.3Btempl = dht11data.4Ba = humh + huml + temph + templerr:If a sum Thenhum = 0temp = 1000EndifReturn


Top Related