صفحه اصلی فروش و نصب سرویس و نگهداری پروژه های الکترونیک ارتباط با ما

BASIC Stamp  2 Program

' {$STAMP BS2}

' {$PBASIC 2.5}

' RelativeHumidityReading.bs2

' Displays relative humidity in the Debug Terminal or the Parallax Serial LCD.

 

LCD            PIN     0               ' Serial output to LCD

 

time           VAR     Word

humidity       VAR     Word

 

LcdBaud        CON     84              ' Baud rate of LCD

RHconstant     CON     12169           ' Relative Humidity Constant * 10    

LcdCls         CON     $0C             ' Clear LCD (use PAUSE 5 after)

LcdCR          CON     $0D             ' Move pos 0 of next line

LcdBLon        CON     $11             ' Backlight on

LcdBLoff       CON     $12             ' Backlight off

LcdOff         CON     $15             ' LCD off

LcdOn1         CON     $16             ' LCD on; cursor off, blink off

LcdLine1       CON     $80             ' Move to line 0, position 0

LcdLine2       CON     $9A             ' Move to line 1, position 5

 

HIGH Lcd                               ' Setup serial output pin

PAUSE 100

 

SEROUT Lcd, LcdBaud, [LcdOn1]          ' Initialize LCD

PAUSE 250

SEROUT Lcd, LcdBaud, [LcdBLon]         ' Turn Backlight on

PAUSE 5

SEROUT Lcd, LcdBaud, [LcdCls]          ' Clear LCD

PAUSE 5

DO

  HIGH 7

  PAUSE 1

  RCTIME 7, 1, time

  time = time * 10

  humidity = (time – RHconstant) / 24

 

  ' Debug Display:

  DEBUG HOME, "Relative Humidity = ", DEC humidity, "%"

 

  ' LCD Display:

  SEROUT Lcd, LcdBaud, [LcdLine1, "RelativeHumidity",

                        LcdLine2, DEC humidity, "%" ]

  PAUSE 100

LOOP

گرفته شده از دیتاشیت سنسور