Norimasa Okamoto
/
pymite
python-on-a-chip online compiler
app board LM75B
# app-board-LM75B mbed NXP LPC1768 # http://mbed.org/users/chris/code/app-board-LM75B/ import mbed import sys class LM75B: LM75B_ADDR=0x90 LM75B_Conf=0x01 LM75B_Temp=0x00 def __init__(self, sda, scl): self.i2c = mbed.I2C(sda, scl) cmd = chr(self.LM75B_Conf) + chr(0) self.i2c.write(self.LM75B_ADDR, cmd, 2, 0) def read_u16(self): cmd = chr(self.LM75B_Temp) + chr(0) self.i2c.write(self.LM75B_ADDR, cmd, 1, 0) # Send command string self.i2c.read(self.LM75B_ADDR, cmd, 2, 0) return (ord(cmd[0])<<8)|ord(cmd[1]) tmp = LM75B('p28', 'p27') while 1: v = tmp.read_u16() print v sys.wait(1000)