blinkM i2c LED example code

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 //blinkM example
00002 #include "mbed.h"
00003 
00004 DigitalOut myled(LED1);
00005 //I2C(PinName sda, PinName scl):
00006 I2C i2c(D7,D6);
00007 int address = 0x09 << 1; //(7bit address left shifted by one)
00008 //http://thingm.com/fileadmin/thingm/downloads/BlinkM_datasheet.pdf
00009 char color[4] = {'n',0xff,0x00,0x00};
00010 char color2[4] = {'n',0x00,0x00,0xff};
00011 int main() {
00012     while(1) {
00013         i2c.write(address, color, 4);
00014         wait(0.2);
00015         i2c.write(address, color2, 4);
00016         wait(0.2);
00017     }
00018 
00019 }