this program works with my pcb only

Dependencies:   Adafruit_LEDBackpack mbed

Committer:
sibu2
Date:
Sun May 03 01:18:16 2015 +0000
Revision:
0:e13c5589c250
led matrix test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sibu2 0:e13c5589c250 1 #include "mbed.h"
sibu2 0:e13c5589c250 2 #include "Adafruit_LEDBackpack.h"
sibu2 0:e13c5589c250 3 #include "Adafruit_GFX.h"
sibu2 0:e13c5589c250 4
sibu2 0:e13c5589c250 5 I2C i2c(p9, p10);
sibu2 0:e13c5589c250 6 DigitalOut myled(LED1);
sibu2 0:e13c5589c250 7
sibu2 0:e13c5589c250 8 Adafruit_8x8matrix matrix1 = Adafruit_8x8matrix(&i2c);
sibu2 0:e13c5589c250 9 Adafruit_8x8matrix matrix2 = Adafruit_8x8matrix(&i2c);
sibu2 0:e13c5589c250 10
sibu2 0:e13c5589c250 11 int main() {
sibu2 0:e13c5589c250 12 int ledon=0;
sibu2 0:e13c5589c250 13
sibu2 0:e13c5589c250 14 matrix1.begin(0x70);
sibu2 0:e13c5589c250 15 matrix2.begin(0x71);
sibu2 0:e13c5589c250 16 matrix1.setBrightness(15);
sibu2 0:e13c5589c250 17 matrix2.setBrightness(4);
sibu2 0:e13c5589c250 18 while(1) {
sibu2 0:e13c5589c250 19 matrix1.clear();
sibu2 0:e13c5589c250 20 matrix2.clear();
sibu2 0:e13c5589c250 21 #if 1
sibu2 0:e13c5589c250 22 for (int y = 0; y < 8; y++) {
sibu2 0:e13c5589c250 23 for (int x = 0; x < 16; x++) {
sibu2 0:e13c5589c250 24 matrix1.drawPixel(x, y, LED_ON);
sibu2 0:e13c5589c250 25 matrix2.drawPixel(15-x, 7-y, LED_ON);
sibu2 0:e13c5589c250 26 matrix1.writeDisplay(); // write the changes we just made to the display
sibu2 0:e13c5589c250 27 matrix2.writeDisplay(); // write the changes we just made to the display
sibu2 0:e13c5589c250 28 wait_ms(10);
sibu2 0:e13c5589c250 29 myled=(ledon^=1);
sibu2 0:e13c5589c250 30 }
sibu2 0:e13c5589c250 31 }
sibu2 0:e13c5589c250 32 wait(1);
sibu2 0:e13c5589c250 33
sibu2 0:e13c5589c250 34 for (int y = 0; y < 8; y++) {
sibu2 0:e13c5589c250 35 for (int x = 0; x < 16; x++) {
sibu2 0:e13c5589c250 36 matrix1.drawPixel(x, y, LED_OFF);
sibu2 0:e13c5589c250 37 matrix2.drawPixel(15-x, 7-y, LED_OFF);
sibu2 0:e13c5589c250 38 matrix1.writeDisplay(); // write the changes we just made to the display
sibu2 0:e13c5589c250 39 matrix2.writeDisplay(); // write the changes we just made to the display
sibu2 0:e13c5589c250 40 wait_ms(10);
sibu2 0:e13c5589c250 41 myled=(ledon^=1);
sibu2 0:e13c5589c250 42 }
sibu2 0:e13c5589c250 43 }
sibu2 0:e13c5589c250 44 #else
sibu2 0:e13c5589c250 45 matrix1.writeDisplay(); // write the changes we just made to the display
sibu2 0:e13c5589c250 46 matrix2.writeDisplay(); // write the changes we just made to the display
sibu2 0:e13c5589c250 47 #endif
sibu2 0:e13c5589c250 48 wait(1);
sibu2 0:e13c5589c250 49 }
sibu2 0:e13c5589c250 50 }