Norimasa Okamoto
/
pymite
python-on-a-chip online compiler
app board RGB
main.py
# 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.write(1.0 - (1.0 - p if p < 1.0 else (p - 2.0 if p > 2.0 else 0.0))) g.write(1.0 - (p if p < 1.0 else (0.0 if p > 2.0 else 2.0 - p))) b.write(1.0 - (0.0 if p < 1.0 else (3.0 - p if p > 2.0 else p - 1.0))) sys.wait(10) # 10ms i += 0.001