“点阵”的版本间的差异
来自Labplus盛思维基百科
Tangliufeng(讨论 | 贡献) (→MicroPython示例) |
Labplus课程组(讨论 | 贡献) (→图形化示例) |
||
(未显示3个用户的10个中间版本) | |||
第4行: | 第4行: | ||
== 技术参数 == | == 技术参数 == | ||
− | * | + | * 工作电压:VCC 3.3-5V |
* I2C数字信号输出 | * I2C数字信号输出 | ||
* 8x8点阵显示 | * 8x8点阵显示 | ||
第22行: | 第22行: | ||
== 使用教程 == | == 使用教程 == | ||
− | |||
=== <small>Arduino示例</small> === | === <small>Arduino示例</small> === | ||
+ | [http://wiki.labplus.cn/images/1/15/Adafruit_LED_matrix8x8_Backpack_Library.rar 点阵库文件下载] | ||
+ | <pre style="color:blue"> | ||
+ | //程序功能:点阵显示笑脸、哭脸、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); | ||
+ | } | ||
+ | |||
+ | </pre> | ||
+ | |||
=== <small>MicroPython示例</small> === | === <small>MicroPython示例</small> === | ||
+ | ==== <small>连接示意图</small> ==== | ||
+ | [[文件:点阵屏连接.jpg|800px|居中]] | ||
<pre style="color:blue"> | <pre style="color:blue"> | ||
+ | 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) | ||
+ | |||
</pre> | </pre> | ||
=== <small>图形化示例</small> === | === <small>图形化示例</small> === | ||
+ | {|- | ||
+ | |程序功能:点阵显示特定的图形 | ||
+ | |- | ||
+ | |[[文件:点阵 1.png|900px|无框|左]] | ||
+ | |-} | ||
+ | |||
+ | == 版本历史记录 == | ||
+ | |||
+ | {| border="1" cellspacing="0" align="left" cellpadding="0" width="60%" style="text-align:center;" | ||
+ | |- style="text-align:center;background-color:#6fa8dc;color:#fffff;" | ||
+ | !width="10%"|Version !!width="15%"| Date !! Note <small>[+]新增[-]删除[^]修复</small> | ||
+ | |- | ||
+ | | V2.0 || || style="text-align:left"| | ||
+ | |} |
2018年5月4日 (五) 10:55的最新版本
概述
8x8点阵显示模块,I2C通讯,操作简单。
技术参数
- 工作电压:VCC 3.3-5V
- I2C数字信号输出
- 8x8点阵显示
- 模块尺寸:24x46x7.5mm
引脚定义
VCC | 电源 |
SDA | I2C数据 |
SCL | I2C时钟 |
GND | 地 |
使用教程
Arduino示例
//程序功能:点阵显示笑脸、哭脸、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)
图形化示例
程序功能:点阵显示特定的图形 | ||
Version | Date | Note [+]新增[-]删除[^]修复 |
---|---|---|
V2.0 |