minimatrix16x8.ino 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /***************************************************
  2. This is a library for our I2C LED Backpacks & FeatherWings
  3. Designed specifically to work with the Adafruit 16x8 LED Matrix FeatherWing
  4. These displays use I2C to communicate, 2 pins are required to
  5. interface. There are multiple selectable I2C addresses. For backpacks
  6. with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
  7. with 3 Address Select pins: 0x70 thru 0x77
  8. Adafruit invests time and resources providing this open source code,
  9. please support Adafruit and open-source hardware by purchasing
  10. products from Adafruit!
  11. Written by Limor Fried/Ladyada for Adafruit Industries.
  12. BSD license, all text above must be included in any redistribution
  13. ****************************************************/
  14. #include <Wire.h>
  15. #include <Adafruit_GFX.h>
  16. #include "Adafruit_LEDBackpack.h"
  17. Adafruit_8x16minimatrix matrix = Adafruit_8x16minimatrix();
  18. void setup() {
  19. //while (!Serial);
  20. Serial.begin(9600);
  21. Serial.println("16x8 LED Mini Matrix Test");
  22. matrix.begin(0x70); // pass in the address
  23. }
  24. static const uint8_t PROGMEM
  25. smile_bmp[] =
  26. { B00111100,
  27. B01000010,
  28. B10100101,
  29. B10000001,
  30. B10100101,
  31. B10011001,
  32. B01000010,
  33. B00111100 },
  34. neutral_bmp[] =
  35. { B00111100,
  36. B01000010,
  37. B10100101,
  38. B10000001,
  39. B10111101,
  40. B10000001,
  41. B01000010,
  42. B00111100 },
  43. frown_bmp[] =
  44. { B00111100,
  45. B01000010,
  46. B10100101,
  47. B10000001,
  48. B10011001,
  49. B10100101,
  50. B01000010,
  51. B00111100 };
  52. void loop() {
  53. matrix.clear();
  54. matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON);
  55. matrix.writeDisplay();
  56. delay(500);
  57. matrix.clear();
  58. matrix.drawBitmap(0, 8, neutral_bmp, 8, 8, LED_ON);
  59. matrix.writeDisplay();
  60. delay(500);
  61. matrix.clear();
  62. matrix.drawBitmap(0, 0, frown_bmp, 8, 8, LED_ON);
  63. matrix.writeDisplay();
  64. delay(500);
  65. matrix.drawPixel(0, 0, LED_ON);
  66. matrix.writeDisplay(); // write the changes we just made to the display
  67. delay(500);
  68. matrix.clear();
  69. matrix.drawLine(0,0, 7,15, LED_ON);
  70. matrix.writeDisplay(); // write the changes we just made to the display
  71. delay(500);
  72. matrix.clear();
  73. matrix.drawRect(0,0, 8,16, LED_ON);
  74. matrix.fillRect(2,2, 4,12, LED_ON);
  75. matrix.writeDisplay(); // write the changes we just made to the display
  76. delay(500);
  77. matrix.clear();
  78. matrix.drawCircle(3,8, 3, LED_ON);
  79. matrix.writeDisplay(); // write the changes we just made to the display
  80. delay(500);
  81. matrix.setTextSize(2);
  82. matrix.setTextWrap(false); // we dont want text to wrap so it scrolls nicely
  83. matrix.setTextColor(LED_ON);
  84. for (int8_t x=0; x>=-64; x--) {
  85. matrix.clear();
  86. matrix.setCursor(x,0);
  87. matrix.print("Hello");
  88. matrix.writeDisplay();
  89. delay(100);
  90. }
  91. matrix.setTextSize(1);
  92. matrix.setTextWrap(false); // we dont want text to wrap so it scrolls nicely
  93. matrix.setTextColor(LED_ON);
  94. matrix.setRotation(1);
  95. for (int8_t x=7; x>=-36; x--) {
  96. matrix.clear();
  97. matrix.setCursor(x,0);
  98. matrix.print("World");
  99. matrix.writeDisplay();
  100. delay(100);
  101. }
  102. matrix.setRotation(0);
  103. }