【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
项目之八:右向流动显示“SOS Call 9-1-1”
实验开源代码
- /*
- 【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
- 实验二百零七:I2C红色8*8LED点阵模块VK16k33驱动1088BS树莓派物联网可扩展编程
- 项目之八:右向流动显示“SOS Call 9-1-1”
- 实验接线:
- VK16k33 UNO
- VIN 5V
- GND GND
- SCL A5
- SDA A4
- */
-
- #include <Wire.h>
- #include <Adafruit_GFX.h>
- #include "Adafruit_LEDBackpack.h" //necessary
-
- Adafruit_8x8matrix matrix = Adafruit_8x8matrix();
-
- void setup() {
-
- matrix.begin(0x70); // pass in the address
- }
-
- static const uint8_t PROGMEM // Setting Static Constants for the LED Matrix
- S_bmp[] = // Declaring the "S" Shape Bitmap for the Matrix
- { B01111111, // String of characters dictates each LED position as on or off on 8x8 gird
- B01111111, // 0 = Off LED 1 = On LED
- B01100000,
- B01111110,
- B01111110,
- B00000110,
- B11111110,
- B11111110 },
-
- O_bmp[] = // Declaring the "O" Shape Bitmap for the Matrix
- { B11111111,
- B11111111,
- B11000011,
- B11000011,
- B11000011,
- B11000011,
- B11111111,
- B11111111 },
-
- S2_bmp[] = // Declaring the second "S" Shape Bitmap for the Matrix
-
- { B01111111,
- B01111111,
- B01110000,
- B01111110,
- B01111110,
- B00000110,
- B11111110,
- B11111110 };
-
- void loop() {
- matrix.clear(); // Starting with clear matrix where all LEDs are off
- matrix.drawBitmap(1, 0, S_bmp, 8, 8, LED_ON); // Drawing the "S" Bitmap according to void setup configuration
- matrix.writeDisplay(); // With 2000 milisecond delay
- delay(2000);
-
- matrix.clear(); // Transitioning with clear matrix where all LEDs are off
- matrix.drawBitmap(1, 0, O_bmp, 7, 8, LED_ON); // Drawing the "O" Bitmap according to void setup configuration
- matrix.writeDisplay(); // With 2000 milisecond delay
- delay(2000);
-
- matrix.clear(); // Transitioning with clear matrix where all LEDs are off
- matrix.drawBitmap(1, 0, S2_bmp, 7, 8, LED_ON); // Drawing the second "S" Bitmap according to void setup configuration
- matrix.writeDisplay(); // With 2000 milisecond delay
- delay(2000);
-
-
- matrix.setTextSize(1); // Setting matrix text size to 1
- matrix.setTextWrap(false); // Preventing text wrapping to scroll text continuously through matrix
- matrix.setTextColor(LED_ON); // Turning LED On
- for (int8_t x=0; x>=-36; x--) { // Setting for loop to position letters side by side for the scroll
- matrix.clear(); // Transitioning with clear matrix where all LEDs are off
- matrix.setCursor(x,0); // Defining letter positions to print one at time side by side
- matrix.print(" Call"); // Printing "Call" on the matrix
- matrix.writeDisplay(); // With 100 milisecond delay
- delay(100);
- }
- matrix.setRotation(0); // Prevent rotation and keep scroll at the same angle
- for (int8_t x=7; x>=-36; x--) { // Setting new for loop to position letters side by side for the scroll
- matrix.clear(); // Transitioning with clear matrix where all LEDs are off
- matrix.setCursor(x,0); // Defining letter positions to print one at time side by side
- matrix.print("9-1-1"); // Printing "9-1-1" on the matrix
- matrix.writeDisplay(); // With 100 milisecond delay
- delay(100);
- }
- }
复制代码
|