/*************************************************** This is a library for our I2C LED Backpacks Designed specifically to work with the Adafruit 16x8 LED Matrix backpacks ----> http://www.adafruit.com/products/2035 ----> http://www.adafruit.com/products/2036 ----> http://www.adafruit.com/products/2037 ----> http://www.adafruit.com/products/2038 ----> http://www.adafruit.com/products/2039 ----> http://www.adafruit.com/products/2040 ----> http://www.adafruit.com/products/2041 ----> http://www.adafruit.com/products/2042 ----> http://www.adafruit.com/products/2043 ----> http://www.adafruit.com/products/2044 ----> http://www.adafruit.com/products/2052 These displays use I2C to communicate, 2 pins are required to interface. There are multiple selectable I2C addresses. For backpacks with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks with 3 Address Select pins: 0x70 thru 0x77 Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, all text above must be included in any redistribution ****************************************************/ #include #include "Adafruit_LEDBackpack.h" #include "Adafruit_GFX.h" Adafruit_8x16matrix matrix0 = Adafruit_8x16matrix(); Adafruit_8x16matrix matrix1 = Adafruit_8x16matrix(); void setup() { Serial.begin(9600); Serial.println("16x8 LED Matrix Test: Carousel"); matrix0.begin(0x70); // pass in the matrix0 address matrix0.setBrightness(15); matrix1.begin(0x71); // pass in the matrix1 address matrix1.setBrightness(15); } int8_t x,y,z; static const uint8_t PROGMEM stripes14_bmp[] = { B00010001, B00100010, B01000100, B10001000, B00010001, B00100010, B01000100, B10001000, B00010001, B00100010, B01000100, B10001000, B00010001, B00100010, B01000100, B10001000, B00010001, /* add 3 extra rows */ B00100010, /* for pointer loop */ B01000100 }; static const uint8_t PROGMEM random8_bmp[] = { B10000011, /* 0 */ B01001001, /* 1 */ B00001100, /* 2 */ B10110000, /* 3 */ B00010001, /* 4 */ B00100010, /* 5 */ B01011000, /* 6 */ B10010100, /* 7 */ B00010010, /* 8 */ B01000101, /* 9 */ B00101000, /* 10 */ B10000011, /* 11 */ B00100100, /* 12 */ B10010010, /* 13 */ B00100001, /* 14 */ B01001010, /* 15 */ B00000110, /* 16 */ B01001100, /* 17 */ B00110000, /* 18 */ B10010100, /* 19 */ B10100001, /* 20 */ B00000101, /* 21 */ B01010001, /* 22 */ B00100010, /* 23 */ B00001001, /* 24 */ B01101000, /* 25 */ B00000011, /* 26 */ B10010010, /* 27 */ B00001010, /* 28 */ B01100100, /* 29 */ B00000110, /* 30 */ B00011000 /* 31 */ }; static const int8_t random16_index[] = { 8, 5, 12, 15, 2, 6, 7, 1, 9, 4, 11, 0, 10, 3, 13, 14 }; void loop() { /* all on */ matrix0.clear(); matrix0.fillRect(0,0, 8,16, LED_ON); matrix0.writeDisplay(); matrix1.clear(); matrix1.fillRect(0,0, 8,16, LED_ON); matrix1.writeDisplay(); delay(7500); for (x=0; x<8; x++) { /* all on */ matrix0.clear(); matrix0.fillRect(0,0, 8,16, LED_ON); matrix0.writeDisplay(); matrix1.clear(); matrix1.fillRect(0,0, 8,16, LED_ON); matrix1.writeDisplay(); delay(750); /* all off */ matrix0.clear(); matrix0.writeDisplay(); matrix1.clear(); matrix1.writeDisplay(); delay(750); } /* stripes */ x=0; y=0; for (z=0; z<80; z++) { matrix0.clear(); matrix0.drawLine((7-x),0, (7-x),15, LED_ON); matrix0.writeDisplay(); matrix1.clear(); matrix1.drawLine((7-y),0, (7-y),15, LED_ON); matrix1.writeDisplay(); x++; if (x > 7) { x=0; } y++; if (y > 5) { y=0; } delay(150); } /* two diagonal stripes */ for (y=0; y<10; y++) { for (x=0; x<4; x++) { matrix0.clear(); matrix0.drawBitmap(0, 0, (stripes14_bmp+x), 8, 16, LED_ON); matrix0.writeDisplay(); matrix1.clear(); matrix1.drawBitmap(0, 0, (stripes14_bmp+x), 8, 16, LED_ON); matrix1.writeDisplay(); delay(300); } } /* pseudorandom */ y = 0; for (z=0; z<80; z++) { x = random16_index[y]; matrix0.clear(); matrix0.drawBitmap(0, 0, (random8_bmp+x), 8, 16, LED_ON); matrix0.writeDisplay(); matrix1.clear(); matrix1.drawBitmap(0, 0, (random8_bmp+x), 8, 16, LED_ON); matrix1.writeDisplay(); y++; if (y > 15) { y=0; } delay(150); } /* all off */ matrix0.clear(); matrix0.writeDisplay(); matrix1.clear(); matrix1.writeDisplay(); delay(4000); }