2013-03-01から1ヶ月間の記事一覧

MPL115A

#include "mbed.h" #include "mbed_debug.h" #if defined(TARGET_KL25Z) SPI spi(PTE1,PTE3,PTE2); // SPI_1 DigitalOut cs(PTE4); #endif int main() { cs = 1; debug(" Read Coefficient(a0,b1,b2,c12)\n"); cs = 0; for(int addr = 0x04; addr <= 0x0b; a…

app-board-LM75B mbed NXP LPC1768

# 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 = ch…

app-board-RGB mbed NXP LPC1768

# app-board-RGB mbed NXP LPC1768 # http://mbed.org/users/chris/code/app-board-RGB/ import mbed import sys r = mbed.PwmOut('p23') g = mbed.PwmOut('p24') b = mbed.PwmOut('p25') r.period(0.001); while 1: i = 0.0 while i < 1.0: p = 3.0 * i r.w…

app-board-LCD mbed NXP LPC1768

# app-board-LCD mbed NXP LPC1768 # http://mbed.org/users/chris/code/app-board-LCD/ # http://mbed.org/users/dreschpe/code/C12832_lcd/ import sys import mbed class C12832_LCD: def __init__(self): self._spi = mbed.SPI('p5','NC','p7') self._re…

FRDM-GPIO

# FRDM-GPIO # http://mbed.org/users/mbed_official/code/FRDM_GPIO/ import mbed import sys gpo = mbed.DigitalOut('PTB8') led = mbed.DigitalOut('LED_RED') while 1: gpo.write(1) led.write(1) # Off sys.wait(2*1000) gpo.write(0) led.write(0) # on…

FRDM_MMA8451Q

# FRDM_MMA8451Q # http://mbed.org/users/mbed_official/code/FRDM_MMA8451Q/ import mbed import sys def float(n): s = 1.0 if n < 0: s = -1.0 n *= -1 f = 0.0 a = 1.0 while n: if n & 1: f += a n >>= 1 a *= 2.0 f *= s return f def abs(a): if a <…

[pymite[KL25Z] FRDM_TSI Touch Sensor

# FRDM_TSI Touch Sensor # http://mbed.org/users/mbed_official/code/FRDM_TSI/ import sys import mbed led = mbed.PwmOut('LED_GREEN'); tsi = mbed.TSISensor() while 1: led.write(1.0 - tsi.readPercentage()) sys.wait(100)