Skip to content

Instantly share code, notes, and snippets.

@ytsuboi
Created November 15, 2014 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ytsuboi/ecd3861a23072bf77814 to your computer and use it in GitHub Desktop.
Save ytsuboi/ecd3861a23072bf77814 to your computer and use it in GitHub Desktop.
EdisonでPCA9622を使ってみた
#include "mraa.hpp"
int main() {
mraa::I2c* i2c;
i2c = new mraa::I2c(6);
i2c->address(0x50);
char init[] = {0x80, 0x00, 0x05, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xFF, 0x00};
i2c->write(init, 21);
char led[8][5] = {
{0x94, 0x01, 0x00, 0x22, 0x22},
{0x94, 0x04, 0x00, 0x88, 0x88},
{0x94, 0x10, 0x00, 0x22, 0x22},
{0x94, 0x40, 0x00, 0x88, 0x88},
{0x94, 0x00, 0x01, 0x22, 0x22},
{0x94, 0x00, 0x04, 0x88, 0x88},
{0x94, 0x00, 0x10, 0x22, 0x22},
{0x94, 0x00, 0x40, 0x88, 0x88} };
while (1) {
for (int i=0; i <= 7; i++) {
i2c->write(led[i], 5);
usleep(1000);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment