HT16K33.ino 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /***************************************************
  2. This is a library for our I2C LED Backpacks
  3. Designed specifically to work with the Adafruit LED Matrix backpacks
  4. ----> http://www.adafruit.com/products/872
  5. ----> http://www.adafruit.com/products/871
  6. ----> http://www.adafruit.com/products/870
  7. These displays use I2C to communicate, 2 pins are required to
  8. interface. There are multiple selectable I2C addresses. For backpacks
  9. with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
  10. with 3 Address Select pins: 0x70 thru 0x77
  11. Adafruit invests time and resources providing this open source code,
  12. please support Adafruit and open-source hardware by purchasing
  13. products from Adafruit!
  14. Written by Limor Fried/Ladyada for Adafruit Industries.
  15. BSD license, all text above must be included in any redistribution
  16. ****************************************************/
  17. #include <Wire.h>
  18. #include <Adafruit_GFX.h>
  19. #include "Adafruit_LEDBackpack.h"
  20. #ifndef _BV
  21. #define _BV(bit) (1<<(bit))
  22. #endif
  23. Adafruit_LEDBackpack matrix = Adafruit_LEDBackpack();
  24. uint8_t counter = 0;
  25. void setup() {
  26. Serial.begin(9600);
  27. Serial.println("HT16K33 test");
  28. matrix.begin(0x70); // pass in the address
  29. }
  30. void loop() {
  31. // paint one LED per row. The HT16K33 internal memory looks like
  32. // a 8x16 bit matrix (8 rows, 16 columns)
  33. for (uint8_t i=0; i<8; i++) {
  34. // draw a diagonal row of pixels
  35. matrix.displaybuffer[i] = _BV((counter+i) % 16) | _BV((counter+i+8) % 16) ;
  36. }
  37. // write the changes we just made to the display
  38. matrix.writeDisplay();
  39. delay(100);
  40. counter++;
  41. if (counter >= 16) counter = 0;
  42. }