Advertisement
Badjer1983

Star Wars Arm communicator

Dec 7th, 2017
315
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /***************************************************
  2.   This is a library for our I2C LED Backpacks
  3.  
  4.   Designed specifically to work with the Adafruit 16x8 LED Matrix backpacks
  5.   ----> http://www.adafruit.com/products/2035
  6.   ----> http://www.adafruit.com/products/2036
  7.   ----> http://www.adafruit.com/products/2037
  8.   ----> http://www.adafruit.com/products/2038
  9.   ----> http://www.adafruit.com/products/2039
  10.   ----> http://www.adafruit.com/products/2040
  11.   ----> http://www.adafruit.com/products/2041
  12.   ----> http://www.adafruit.com/products/2042
  13.   ----> http://www.adafruit.com/products/2043
  14.   ----> http://www.adafruit.com/products/2044
  15.   ----> http://www.adafruit.com/products/2052
  16.  
  17.   These displays use I2C to communicate, 2 pins are required to
  18.   interface. There are multiple selectable I2C addresses. For backpacks
  19.   with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
  20.   with 3 Address Select pins: 0x70 thru 0x77
  21.  
  22.   Adafruit invests time and resources providing this open source code,
  23.   please support Adafruit and open-source hardware by purchasing
  24.   products from Adafruit!
  25.  
  26.   Written by Limor Fried/Ladyada for Adafruit Industries.  
  27.   BSD license, all text above must be included in any redistribution
  28.  ****************************************************/
  29.  
  30. #include <Wire.h>
  31. #include <Adafruit_GFX.h>
  32. #include "Adafruit_LEDBackpack.h"
  33.  
  34. Adafruit_8x16matrix matrix = Adafruit_8x16matrix();
  35.  
  36. void setup() {
  37.   Serial.begin(9600);
  38.   Serial.println("jerry");
  39.  
  40.   matrix.begin(0x70);  // pass in the address
  41. }
  42.  
  43. static const uint8_t PROGMEM
  44.   Full_bmp[] =
  45.   { B11111111,
  46.     B11111111,
  47.     B11111111,
  48.     B11111111,
  49.     B11111111,
  50.     B11111111,
  51.     B11111111,
  52.     B11111111 },
  53.   X_bmp[] =
  54.   { B10000001,
  55.     B11000011,
  56.     B11100111,
  57.     B11111111,
  58.     B11111111,
  59.     B11100111,
  60.     B11000011,
  61.     B10000001 },
  62.   square_bmp[] =
  63.   { B11111111,
  64.     B10000001,
  65.     B10000001,
  66.     B10000001,
  67.     B10000001,
  68.     B10000001,
  69.     B10000001,
  70.     B11111111 },
  71.    smsquare_bmp[] =
  72.   { B00000000,
  73.     B00000000,
  74.     B00111100,
  75.     B00111100,
  76.     B00111100,
  77.     B00111100,
  78.     B00000000,
  79.     B00000000 };
  80.  
  81. void loop() {
  82.  
  83.   matrix.clear();
  84.   matrix.drawBitmap(0, 0, Full_bmp, 8, 8, LED_ON);
  85.   matrix.drawBitmap(0, 8, X_bmp, 8, 8, LED_ON);
  86.   matrix.writeDisplay();
  87.   delay(1000);
  88.  
  89.   matrix.clear();
  90.   matrix.drawBitmap(0, 8, smsquare_bmp, 8, 8, LED_ON);
  91.   matrix.drawBitmap(0, 0, square_bmp, 8, 8, LED_ON);
  92.   matrix.writeDisplay();
  93.   delay(1000);
  94.  
  95.   matrix.clear();
  96.   matrix.drawBitmap(0, 0, smsquare_bmp, 8, 8, LED_ON);
  97.   matrix.drawBitmap(0, 8, Full_bmp, 8, 8, LED_ON);
  98.   matrix.writeDisplay();
  99.   delay(1000);
  100.  
  101.   matrix.clear();
  102.   matrix.drawBitmap(0, 8, Full_bmp, 8, 8, LED_ON);
  103.   matrix.drawBitmap(0, 0, square_bmp, 8, 8, LED_ON);
  104.   matrix.writeDisplay();
  105.   delay(1000);
  106.  
  107.   matrix.clear();      // clear display
  108.   matrix.drawPixel(6, 10, LED_ON);  
  109.   matrix.writeDisplay();  // write the changes we just made to the display
  110.   delay(1000);
  111.  
  112.   matrix.clear();
  113.   matrix.drawLine(0,0,15,15, LED_ON);
  114.   matrix.drawLine(0,15,15,0, LED_ON);
  115.   matrix.writeDisplay();  // write the changes we just made to the display
  116.   delay(1000);
  117.  
  118.   matrix.clear();
  119.   matrix.drawRect(15,15, 0,0, LED_ON);
  120.   matrix.fillRect(0,1, 0,0, LED_ON);
  121.   matrix.writeDisplay();  // write the changes we just made to the display
  122.   delay(1000);
  123.  
  124.   matrix.clear();
  125.   matrix.drawCircle(3,3, 3, LED_ON);
  126.   matrix.drawCircle(12,12, 3, LED_ON);
  127.   matrix.writeDisplay();  // write the changes we just made to the display
  128.   delay(1000);
  129.  
  130.   matrix.setTextSize(1);
  131.   matrix.setTextWrap(false);  // we dont want text to wrap so it scrolls nicely
  132.   matrix.setTextColor(LED_ON);
  133.   for (int8_t x=0; x>=-64; x--) {
  134.     matrix.clear();
  135.     matrix.setCursor(x,0);
  136.     matrix.print("Hello");
  137.     matrix.writeDisplay();
  138.     delay(50);
  139.   }
  140.  
  141.   matrix.setTextSize(1);
  142.   matrix.setTextWrap(false);  // we dont want text to wrap so it scrolls nicely
  143.   matrix.setTextColor(LED_ON);
  144.   matrix.setRotation(1);
  145.   for (int8_t x=7; x>=-36; x--) {
  146.     matrix.clear();
  147.     matrix.setCursor(x,0);
  148.     matrix.print("World");
  149.     matrix.writeDisplay();
  150.     delay(100);
  151.   }
  152.   matrix.setRotation(2);
  153. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement