## Introduction: Intel Edison With Grove LCD, Temperature Sensor and Infrared Sensor

Grove LCD、Temperature sensor 與 Infrared sensor

mraa library中有完整的使用方式

Grove的官方資料與範例也相當齊全

## Step 1: Grove LCD

import pyupm_i2clcd as lcd

myLcd = lcd.Jhd1313m1(0, 0x3E, 0x62)

myLcd.setCursor(1,0)
myLcd.write('Temperature ')

myLcd.write(str(temperature))

.....

## Step 2: Temperature Sensor

B = 3975

a_pin = mraa.Aio(0)

while True:

pin_value = a_pin.read()

resistance = (1023.0 - pin_value)*10000.0/pin_value
temperature = 1.0/(math.log10(resistance/10000.0)/B+1/298.15)-273.15

## Step 3: Infrared Sensor

detect = mraa.Gpio(7)
detect.dir(mraa.DIR_IN)

while True:

people = detect.read()

if(people):

myLcd.setColor(255, 0, 0)

myLcd.setCursor(0,0)

myLcd.write('People coming....')

else:

myLcd.setColor(0, 255, 0)

myLcd.setCursor(0,0)

myLcd.write('Nobody here....')

## Step 4: Mix All Together

import mraa

import time

import pyupm_i2clcd as lcd

import math

B = 3975

detect = mraa.Gpio(7)

detect.dir(mraa.DIR_IN)

a_pin = mraa.Aio(0)

while True:

people = detect.read()

pin_value = a_pin.read()

resistance = (1023.0 - pin_value)*10000.0/pin_value

temperature = 1.0/(math.log10(resistance/10000.0)/B+1/298.15)-273.15

myLcd.setCursor(1,0)

myLcd.write('Temperature ')

myLcd.write(str(temperature))

if(people):

myLcd.setColor(255, 0, 0)

myLcd.setCursor(0,0)

myLcd.write('People coming....')

else:

myLcd.setColor(0, 255, 0)

myLcd.setCursor(0,0)

myLcd.write('Nobody here....')

time.sleep(1)