这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录前一修订版 | |||
ocrobot:kit:arduino_star_kit:tutorial018 [2017/10/04 07:58] – 弘毅 | ocrobot:kit:arduino_star_kit:tutorial018 [2023/06/07 04:23] (当前版本) – 外部编辑 127.0.0.1 | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ======使用IIC点阵显示数字====== | ||
+ | <WRAP center round info 100%> | ||
+ | 这个例程展示了如何使用IIC点阵显示数字。 | ||
+ | </ | ||
+ | IIC 即Inter-Integrated Circuit(集成电路总线),这种总线类型是由飞利浦半导体公司在八十年代初设计出来的,主要是用来连接整体电路,IIC是一种多向控制总线,也就是说多个芯片可以连接到同一总线结构下,同时每个芯片都可以作为实时数据传输的控制源。这种方式简化了信号传输总线。 | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | =====搭建电路====== | ||
+ | 用到OCROBOT IIC 8X8点阵,硬件连接如下图,VCC GND SDA SCL按照对应管脚接好即可。 | ||
+ | {{: | ||
+ | =====代码===== | ||
+ | <code cpp> | ||
+ | #include < | ||
+ | #include " | ||
+ | #include " | ||
+ | |||
+ | Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix(); | ||
+ | |||
+ | void setup() { | ||
+ | Serial.begin(9600); | ||
+ | Serial.println(" | ||
+ | |||
+ | matrix.begin(0x70); | ||
+ | } | ||
+ | |||
+ | 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.setRotation(3); | ||
+ | matrix.clear(); | ||
+ | matrix.drawBitmap(0, | ||
+ | matrix.writeDisplay(); | ||
+ | delay(500); | ||
+ | |||
+ | matrix.clear(); | ||
+ | matrix.drawBitmap(0, | ||
+ | matrix.writeDisplay(); | ||
+ | delay(500); | ||
+ | |||
+ | matrix.clear(); | ||
+ | matrix.drawBitmap(0, | ||
+ | matrix.writeDisplay(); | ||
+ | delay(500); | ||
+ | |||
+ | matrix.clear(); | ||
+ | matrix.drawPixel(0, | ||
+ | matrix.writeDisplay(); | ||
+ | delay(500); | ||
+ | |||
+ | matrix.clear(); | ||
+ | matrix.drawLine(0, | ||
+ | matrix.writeDisplay(); | ||
+ | delay(500); | ||
+ | |||
+ | matrix.clear(); | ||
+ | matrix.drawRect(0, | ||
+ | matrix.fillRect(2, | ||
+ | matrix.writeDisplay(); | ||
+ | delay(500); | ||
+ | |||
+ | matrix.clear(); | ||
+ | matrix.drawCircle(3, | ||
+ | matrix.writeDisplay(); | ||
+ | delay(500); | ||
+ | |||
+ | matrix.setTextWrap(false); | ||
+ | matrix.setTextSize(1); | ||
+ | matrix.setTextColor(LED_GREEN); | ||
+ | matrix.setRotation(3); | ||
+ | for (int8_t x=7; x>=-72; x--) { | ||
+ | matrix.clear(); | ||
+ | matrix.setCursor(x, | ||
+ | matrix.print(" | ||
+ | matrix.writeDisplay(); | ||
+ | delay(100); | ||
+ | } | ||
+ | matrix.setTextWrap(false); | ||
+ | matrix.setTextSize(1); | ||
+ | matrix.setTextColor(LED_YELLOW); | ||
+ | matrix.setRotation(3); | ||
+ | for (int8_t x=7; x>=-72; x--) { | ||
+ | matrix.clear(); | ||
+ | matrix.setCursor(x, | ||
+ | matrix.print(" | ||
+ | matrix.writeDisplay(); | ||
+ | delay(100); | ||
+ | } | ||
+ | matrix.setTextWrap(false); | ||
+ | matrix.setTextSize(1); | ||
+ | matrix.setTextColor(LED_RED); | ||
+ | matrix.setRotation(3); | ||
+ | for (int8_t x=7; x>=-72; x--) { | ||
+ | matrix.clear(); | ||
+ | matrix.setCursor(x, | ||
+ | matrix.print(" | ||
+ | matrix.writeDisplay(); | ||
+ | delay(100); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | <WRAP center round important 100%> | ||
+ | 注意: | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | </ | ||
+ | {{youku> | ||
+ | =====下载===== | ||
+ | 库:{{: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | [[ocrobot: |