blinkM i2c LED example code
Dependencies: mbed
main.cpp@0:38e0b84ac173, 2015-09-16 (annotated)
- Committer:
- bjo3rn
- Date:
- Wed Sep 16 18:34:26 2015 +0000
- Revision:
- 0:38e0b84ac173
initial commit;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bjo3rn | 0:38e0b84ac173 | 1 | //blinkM example |
bjo3rn | 0:38e0b84ac173 | 2 | #include "mbed.h" |
bjo3rn | 0:38e0b84ac173 | 3 | |
bjo3rn | 0:38e0b84ac173 | 4 | DigitalOut myled(LED1); |
bjo3rn | 0:38e0b84ac173 | 5 | //I2C(PinName sda, PinName scl): |
bjo3rn | 0:38e0b84ac173 | 6 | I2C i2c(D7,D6); |
bjo3rn | 0:38e0b84ac173 | 7 | int address = 0x09 << 1; //(7bit address left shifted by one) |
bjo3rn | 0:38e0b84ac173 | 8 | //http://thingm.com/fileadmin/thingm/downloads/BlinkM_datasheet.pdf |
bjo3rn | 0:38e0b84ac173 | 9 | char color[4] = {'n',0xff,0x00,0x00}; |
bjo3rn | 0:38e0b84ac173 | 10 | char color2[4] = {'n',0x00,0x00,0xff}; |
bjo3rn | 0:38e0b84ac173 | 11 | int main() { |
bjo3rn | 0:38e0b84ac173 | 12 | while(1) { |
bjo3rn | 0:38e0b84ac173 | 13 | i2c.write(address, color, 4); |
bjo3rn | 0:38e0b84ac173 | 14 | wait(0.2); |
bjo3rn | 0:38e0b84ac173 | 15 | i2c.write(address, color2, 4); |
bjo3rn | 0:38e0b84ac173 | 16 | wait(0.2); |
bjo3rn | 0:38e0b84ac173 | 17 | } |
bjo3rn | 0:38e0b84ac173 | 18 | |
bjo3rn | 0:38e0b84ac173 | 19 | } |