“点阵”的版本间的差异
来自Labplus盛思维基百科
Jiangzhaohui(讨论 | 贡献) (→Arduino示例) |
Jiangzhaohui(讨论 | 贡献) (→Arduino示例) |
||
第25行: | 第25行: | ||
[http://wiki.labplus.cn/images/1/15/Adafruit_LED_matrix8x8_Backpack_Library.rar Adafruit_LED_matrix8x8_Backpack_Library点击下载] | [http://wiki.labplus.cn/images/1/15/Adafruit_LED_matrix8x8_Backpack_Library.rar Adafruit_LED_matrix8x8_Backpack_Library点击下载] | ||
<pre style="color:blue"> | <pre style="color:blue"> | ||
+ | //程序功能:点阵显示笑脸、哭脸、hello、逆时针90°的world等// | ||
#include <Wire.h> | #include <Wire.h> | ||
#include "Adafruit_LEDBackpack.h" | #include "Adafruit_LEDBackpack.h" |
2018年1月8日 (一) 15:15的版本
概述
8x8点阵显示模块,I2C通讯,操作简单。
技术参数
- 工作电压:VCC 3.3-5V
- I2C数字信号输出
- 8x8点阵显示
- 模块尺寸:24x46x7.5mm
引脚定义
VCC | 电源 |
SDA | I2C数据 |
SCL | I2C时钟 |
GND | 地 |
使用教程
Arduino示例
Adafruit_LED_matrix8x8_Backpack_Library点击下载
//程序功能:点阵显示笑脸、哭脸、hello、逆时针90°的world等// #include <Wire.h> #include "Adafruit_LEDBackpack.h" #include "Adafruit_GFX.h" Adafruit_8x8matrix matrix = Adafruit_8x8matrix(); void setup() { Serial.begin(9600); Serial.println("8x8 LED Matrix Test"); matrix.begin(0x70); // pass in the address } static const uint8_t PROGMEM smile_bmp[] = { B00111100, B01000010, B10100101, B10000001, B10100101, B10011001, B01000010, B00111100 }, neutral_bmp[] = { B00111100, B01000010, B10100101, B10000001, B10111101, B10000001, B01000010, B00111100 }, frown_bmp[] = { B00111100, B01000010, B10100101, B10000001, B10011001, B10100101, B01000010, B00111100 }; void loop() { matrix.clear(); matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON); matrix.writeDisplay(); delay(500); matrix.clear(); matrix.drawBitmap(0, 0, neutral_bmp, 8, 8, LED_ON); matrix.writeDisplay(); delay(500); matrix.clear(); matrix.drawBitmap(0, 0, frown_bmp, 8, 8, LED_ON); matrix.writeDisplay(); delay(500); matrix.clear(); // clear display matrix.drawPixel(0, 0, LED_ON); matrix.writeDisplay(); // write the changes we just made to the display delay(500); matrix.clear(); matrix.drawLine(0,0, 7,7, LED_ON); matrix.writeDisplay(); // write the changes we just made to the display delay(500); matrix.clear(); matrix.drawRect(0,0, 8,8, LED_ON); matrix.fillRect(2,2, 4,4, LED_ON); matrix.writeDisplay(); // write the changes we just made to the display delay(500); matrix.clear(); matrix.drawCircle(3,3, 3, LED_ON); matrix.writeDisplay(); // write the changes we just made to the display delay(500); matrix.setTextSize(1); matrix.setTextWrap(false); // we dont want text to wrap so it scrolls nicely matrix.setTextColor(LED_ON); for (int8_t x=0; x>=-36; x--) { matrix.clear(); matrix.setCursor(x,0); matrix.print("Hello"); matrix.writeDisplay(); delay(100); } matrix.setRotation(3); for (int8_t x=7; x>=-36; x--) { matrix.clear(); matrix.setCursor(x,0); matrix.print("World"); matrix.writeDisplay(); delay(100); } matrix.setRotation(0); }
MicroPython示例
连接示意图
from microbit import * ''' acsii_charactor = [ [0x30,0x48,0x48,0x48,0x48,0x48,0x30,0x00], # 0 [0x20,0x60,0x20,0x20,0x20,0x20,0x70,0x00], # 1 [0x30,0x48,0x08,0x10,0x20,0x40,0x78,0x00], # 2 [0x30,0x48,0x08,0x30,0x08,0x48,0x30,0x00], # 3 [0x10,0x30,0x30,0x50,0x50,0x78,0x10,0x00], # 4 [0x78,0x40,0x40,0x70,0x08,0x08,0x70,0x00], # 5 [0x30,0x48,0x40,0x70,0x48,0x48,0x30,0x00], # 6 [0x78,0x48,0x08,0x10,0x20,0x20,0x20,0x00], # 7 [0x30,0x48,0x48,0x30,0x48,0x48,0x30,0x00], # 8 [0x30,0x48,0x48,0x38,0x08,0x48,0x30,0x00], # 9 [0x30,0x48,0x48,0x48,0x78,0x48,0x48,0x00], # A [0x70,0x48,0x48,0x70,0x48,0x48,0x70,0x00], # B [0x30,0x48,0x40,0x40,0x40,0x48,0x30,0x00], # C [0x70,0x48,0x48,0x48,0x48,0x48,0x70,0x00], # D [0x78,0x40,0x40,0x70,0x40,0x40,0x78,0x00], # E [0x78,0x40,0x40,0x70,0x40,0x40,0x40,0x00], # F [0x30,0x48,0x40,0x58,0x48,0x48,0x30,0x00], # G [0x48,0x48,0x48,0x78,0x48,0x48,0x48,0x00], # H [0x70,0x20,0x20,0x20,0x20,0x20,0x70,0x00], # I [0x08,0x08,0x08,0x08,0x48,0x48,0x30,0x00], # J [0x48,0x48,0x50,0x60,0x50,0x48,0x48,0x00], # K [0x40,0x40,0x40,0x40,0x40,0x40,0x78,0x00], # L [0x48,0x78,0x78,0x48,0x48,0x48,0x48,0x00], # M [0x48,0x68,0x68,0x58,0x58,0x48,0x48,0x00], # N [0x78,0x48,0x48,0x48,0x48,0x48,0x78,0x00], # O [0x70,0x48,0x48,0x70,0x40,0x40,0x40,0x00], # P [0x30,0x48,0x48,0x48,0x68,0x58,0x38,0x00], # Q [0x70,0x48,0x48,0x70,0x60,0x50,0x48,0x00], # R [0x30,0x48,0x40,0x30,0x08,0x48,0x30,0x00], # S [0x78,0x20,0x20,0x20,0x20,0x20,0x20,0x00], # T [0x48,0x48,0x48,0x48,0x48,0x48,0x30,0x00], # U [0x48,0x48,0x48,0x48,0x30,0x30,0x30,0x00], # V [0x48,0x48,0x48,0x48,0x78,0x78,0x48,0x00], # W [0x48,0x48,0x30,0x30,0x30,0x48,0x48,0x00], # X [0x88,0x88,0x50,0x20,0x20,0x20,0x20,0x00], # Y [0x78,0x08,0x10,0x30,0x20,0x40,0x78,0x00], # Z [0x00,0x66,0x99,0x81,0x81,0x42,0x24,0x18], # 显示桃心 ''' HT16K33_ADDR = 0x70 HT16K33_BLINK_CMD = 0x80 HT16K33_BLINK_DISPLAYON = 0x01 HT16K33_BLINK_OFF = 0 HT16K33_BLINK_2HZ = 1 HT16K33_BLINK_1HZ = 2 HT16K33_BLINK_HALFHZ = 3 HT16K33_CMD_BRIGHTNESS = 0xE0 TM1650_CDigits = [0x00] def HT16K33SetBrightness(brightness): b = brightness if b > 15: b = 15 var = HT16K33_CMD_BRIGHTNESS | b i2c.write(HT16K33_ADDR, bytearray([var])) def HT16K33BlinkRate(rate): r = rate if r > 3: r = 0 r <<= 1 var = HT16K33_BLINK_CMD | HT16K33_BLINK_DISPLAYON | r i2c.write(HT16K33_ADDR, bytearray([var])) def HT16K33Init(): i2c.write(HT16K33_ADDR, bytearray([0x21])) HT16K33BlinkRate(HT16K33_BLINK_OFF) HT16K33SetBrightness(15) def HT16K33WriteDisplay(x): # var = bytearray([0x00, x[0],0x00, x[1],0x00, x[2],0x00, x[3],0x00, x[4],0x00, x[5],0x00, x[6],0x00, x[7],0x00]) i2c.write(HT16K33_ADDR, var) # text code HT16K33Init() fill_bitmap = bytearray([0x30,0x48,0x48,0x48,0x78,0x48,0x48,0x00]) #display "A" HT16K33WriteDisplay(fill_bitmap)