OCROBOT入门教程018--使用IIC点阵显示数字
本帖最后由 董董soul 于 2016-10-27 11:09 编辑IIC 即Inter-Integrated Circuit(集成电路总线),这种总线类型是由飞利浦半导体公司在八十年代初设计出来的,主要是用来连接整体电路,IIC是一种多向控制总线,也就是说多个芯片可以连接到同一总线结构下,同时每个芯片都可以作为实时数据传输的控制源。这种方式简化了信号传输总线。
IIC串行总线一般有两根信号线,一根是双向的数据线SDA,另一根是时钟线SCL。所有接到IIC总线设备上的串行数据SDA都接到总线的SDA上,各设备的时钟线SCL接到总线的SCL上。
IIC总线是各种总线中使用信号线最少,并具有自动寻址、多主机时钟同步和仲裁等功能的总线。使用I2C总线连接各种模块十分方便灵活,我们未来介绍各种模块时会遇到大量的IIC模块。
这次我们就会用到OCROBOT IIC 8X8点阵,硬件连接如下图,VCC GND SDA SCL按照对应管脚接好即可。
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();
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.setRotation(3);
matrix.clear();
matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_GREEN);
matrix.writeDisplay();
delay(500);
matrix.clear();
matrix.drawBitmap(0, 0, neutral_bmp, 8, 8, LED_YELLOW);
matrix.writeDisplay();
delay(500);
matrix.clear();
matrix.drawBitmap(0, 0, frown_bmp, 8, 8, LED_RED);
matrix.writeDisplay();
delay(500);
matrix.clear(); // clear display
matrix.drawPixel(0, 0, LED_GREEN);
matrix.writeDisplay();// write the changes we just made to the display
delay(500);
matrix.clear();
matrix.drawLine(0,0, 7,7, LED_YELLOW);
matrix.writeDisplay();// write the changes we just made to the display
delay(500);
matrix.clear();
matrix.drawRect(0,0, 8,8, LED_RED);
matrix.fillRect(2,2, 4,4, LED_GREEN);
matrix.writeDisplay();// write the changes we just made to the display
delay(500);
matrix.clear();
matrix.drawCircle(3,3, 3, LED_YELLOW);
matrix.writeDisplay();// write the changes we just made to the display
delay(500);
matrix.setTextWrap(false);// we dont want text to wrap so it scrolls nicely
matrix.setTextSize(1);
matrix.setTextColor(LED_GREEN);
matrix.setRotation(3); //FANG XIANG
for (int8_t x=7; x>=-72; x--) {
matrix.clear();
matrix.setCursor(x,0);
matrix.print("Hello OCROBOT");
matrix.writeDisplay();
delay(100);
}
matrix.setTextWrap(false);// we dont want text to wrap so it scrolls nicely
matrix.setTextSize(1);
matrix.setTextColor(LED_YELLOW);
matrix.setRotation(3);
for (int8_t x=7; x>=-72; x--) {
matrix.clear();
matrix.setCursor(x,0);
matrix.print("1234567890");
matrix.writeDisplay();
delay(100);
}
matrix.setTextWrap(false);// we dont want text to wrap so it scrolls nicely
matrix.setTextSize(1);
matrix.setTextColor(LED_RED);
matrix.setRotation(3);
for (int8_t x=7; x>=-72; x--) {
matrix.clear();
matrix.setCursor(x,0);
matrix.print("ha~! ha~! ha~!");
matrix.writeDisplay();
delay(100);
}
}
http://player.youku.com/player.php/sid/XNzE1OTM4NjI4/v.swf
注意:
如果使用的IDE编译是提示Robot_Control什么什么编译报错,进入libraries文件夹找到Robot_Control与Robot_Motor两个文件夹,删除。就可以正常编译了。
这是因为与Robot_Control的函数名冲突了。。。 代码能否稍微注释下 Friday 发表于 2014-7-26 11:13 static/image/common/back.gif
代码能否稍微注释下
这个。。。国外资料注释都写的很少。。。出HoneyBee教程时重新注释下吧 Adafruit_LED_Backpack_Library.zip Adafruit_GFX_Library.zip 这两个库是标准库还是扩展库呢? 能不能稍微说明下各自的功能分别是啥? Friday 发表于 2014-8-6 08:35 static/image/common/back.gif
Adafruit_LED_Backpack_Library.zip Adafruit_GFX_Library.zip 这两个库是标准库还是扩展库呢? 能 ...
一个是驱动库,一个是绘图库。 弘毅 发表于 2014-8-7 12:11 static/image/common/back.gif
一个是驱动库,一个是绘图库。
哦 原来如此 请问有没有这两个类库的说明??? Zzzz 发表于 2014-10-7 16:31 static/image/common/back.gif
请问有没有这两个类库的说明???
没。。只能看源码了 话说楼主的i2c 8*8图标是自己设计的么 想自己画一些图案的画 有什么软件可以辅助一下么 С罗 发表于 2015-11-22 00:36 static/image/common/back.gif
想自己画一些图案的画 有什么软件可以辅助一下么
AI~ 我的IDE上显示错误为“Adafruit_BicolorMatrix”does not name a type 请问有没有什么解决方案?急! 2209459971 发表于 2015-12-3 21:11 static/image/common/back.gif
我的IDE上显示错误为“Adafruit_BicolorMatrix”does not name a type 请问有没有什么解决方案?急!
库没加载,检查库。 这个IIC点阵是不是不能和串口输出一起用啊,我看了那个红外接收的实验试着用点阵显示遥控器上的数字,但是要有matrix.begin(0x70);这一句的话,串口就接收不到数据,而且TX也不会闪
页:
[1]