日立 nba竞猜.是一个液晶驱动芯片组,通常驾驶2线16 字符显示。您可以获得许多不同的屏幕尺寸。 16x4,20x4, 80x1。无论如何,芯片组,因此仍然存在驾驶软件 the same.
这些类型的显示成本非常低,可以显示任何ASCII文本 你要。此外,您还可以生成自己的字符。使用这些 可以创建一个简单的条形图以显示图形表示 of voltage etc.
日立 nba竞猜.模块的后视图:
nba竞猜能够以8位模式操作,即更快(但看到 以下),但这意味着您需要11个单片机引脚。这是一个折扣 您可以使用的微控制器销的速度和数量之间。实际上 速度并不重要,因为驱动的数据量 显示器很低,nba竞猜接口的定时意味着有很多 无论如何需要37us延迟(编写命令后)。液晶 库使用100us安全侧。注意一个命令:清除显示 takes 2ms.
由于只需要,4位模式更适合微控制器 大约6个引脚。在nba竞猜中,您仍然有8位操作,所以4位 模式您执行两份写入芯片内的8位数量。
电路非常简单,这里仅使用6个线 nba竞猜:
与之连接 Arduino are:
LCD名称 | Arduno Pin. |
---|---|
卢比 | 5 |
E | 4 |
D4 | 3 |
D5 | 2 |
D6 | 1 |
D7 | 0 |
5V | arduino. 5v. |
GND. | arduino gnd. |
下图显示了4个运行的nba竞猜显示连接 bit mode:
连接如下:
描述 | 钢丝 |
---|---|
卢比 | 棕色的 |
E | 蓝色 |
D4..D7 | 灰色的 |
10k pot - 刮水器到vo | 黄色的 |
VCC,VDD(5V) | 橙子 |
GND. | 黑褐色 |
470R | 到LCD背光阳极 |
版本:1.6.4
这里使用的库是lquidcrystal 1.01 - 您可以轻松安装它 the Arduino IDE.
如果您在单击菜单时没有将库视为条目:
草图 - >Include Library
然后选择管理库:
草图 - >Include Library -->Manage Libraries...
使用该搜索并安装液晶系统"Filter Your Search" form.
这是一个简单的例子。注意自从我们只有以来的主循环没有代码 想要初始化并显示文本而不进行其他任何操作。
#include <LiquidCrystal.h>
#define LCD_RS 5 // Register select
#define LCD_E 4 // Enable
#define LCD_D4 3
#define LCD_D5 2
#define LCD_D6 1
#define LCD_D7 0
// * LCD R/W pin to ground
// * 10K pot:
// * ends to +5V and ground
// * wiper to LCD VO pin (pin 3)
// A Anode Backlight R (~470R) to Vdd
// K kathode to GND, VSS = GND, Vdd = 5V.
// initialize the library with the numbers of the interface pins
液晶 LCD( lcd_rs, lcd_e, lcd_d4, lcd_d5, lcd_d6, lcd_d7);
void 设置() {
lcd.begin(16, 2); // set up the LCD's columns and rows
lcd.print("How to Drive an");
lcd.setCursor(0, 1);
lcd.print("nba竞猜 16x2 LCD");
}
void loop() {
}
日立 nba竞猜.有许多命令,这里最有用: 初始化,XY位置设置和打印:
类实例性级别
液晶 <object> (pins...)
这个实例化过程也包括别针 in use
公共类职能
开始(16,2)
告诉软件你有什么显示 - 必须是 在其他命令之前调用。
setcursor(x,y)
左上角是(0,0)
打印(数据[ ,base]) - [] optional
这是一个重载的功能,可以打印任何一个 三个数字或字符串。如果您使用数字char,byte,int或long) 您还可以选择将哪个基础转换为使用三个字母 首字母缩略词,垃圾箱,DEC,OCT或十六进制。
一个有用的功能是用户生成的字符 function:
crectechar(Uint8_t addr,uint8_t data[]);
这定义了作为生成的用户使用的数据 character.
使用主类构造函数创建一个对象(在这种情况下 液晶)如下(这里创建的对象标记为LCD):
液晶 lcd(lcd_rs,lcd_e,lcd_d4,lcd_d5,lcd_d6,lcd_d7);
注意:这也用于初始化内部 使用引脚的数据结构。
创建后,您可以使用该库访问类库功能 实例化对象(LCD)随后是一段时间,然后是公共类 功能:因此,打印出一些文本的LCD对象(上图)您会的 type:
lcd.print("My text");
如上所述,此函数超载以允许数字输出:
lcd.print((char)35,bin);
这里's的液晶公共图书馆命令的全部列表 Hitachi nba竞猜 :
public:
液晶(uint8_t rs, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
液晶(uint8_t rs, uint8_t rw, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
液晶(uint8_t rs, uint8_t rw, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);
液晶(uint8_t rs, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3);
The above object creators (constructor prototypes) differ only in the number of
parameters. For example the first and second differ only in that the 1st one does
not have the rw variable, and both operate the 8 bit interface. Then next two
again only differ in the rw variable and operate the 4 bit interface.
All these constructors are guided in code to call the "init" function below (look
for a magic number in the library source code that indicates when rw is not to
be used (it is 255)).
void 在it(uint8_t fourbitmode, uint8_t rs, uint8_t rw, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
The following function allows the underlying functions to know how big your
display is and whether a large font is in use.
void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
The following fuctions are self-evident, taking no arguments:
void clear();
void home();
void noDisplay();
void display();
void noBlink();
void blink();
void noCursor();
void cursor();
void scrollDisplayLeft();
void scrollDisplayRight();
void leftToRight();
void rightToLeft();
void autoscroll();
void noAutoscroll();
The y position of the display is often strange for larger displays as two
nba竞猜's are used so the start address for each row needs to be set (in some
cases).
void setRowOffsets(在t row1, 在t row2, 在t row3, 在t row4);
void createChar(uint8_t, uint8_t[]);
void setCursor(uint8_t, uint8_t);
virtual size_t write(uint8_t);
This one is a little different as it uses the print class. That is one good thing
about OOP. In this case the serial print class allows you to re-write the "write"
function that actually accesses the hardware. So instead of directing the serial
data to the serial port you can re-direct the data to the LCD but retain all the
number formatting code!
using Print::write;
在审查LCD代码的操作时,我发现了这一有趣 snippet:
void 液晶::write4bits(uint8_t value) {
for (在t i = 0; i < 4; i++) {
pinMode(_data_pins[i], OUTPUT);
digitalWrite(_data_pins[i], (value >> i) & 0x01);
}
pulseEnable();
}
那里'对代码没有错,但它必须做很多操纵 使操作通用。它展示了如何使代码概括和 易于使用的性能牺牲。有两个有趣的 零件到此操作
首先,每次写入LCD时都会设置PIN模式。 这将确保如果其他代码错误地错误地设置了引脚方向 那么这会覆盖它。通常一个端口专用于一个操作 引脚模式应设置"setup"常规。它在这里完成的方式是 "safe"但是,每个液晶写作操作都会击中大表现。
其次,为了操纵每个数据位,将它引导到输出需要几个 涉及选择引脚的操作,然后右移右转。它's 聪明,在所有情况下工作,但再次有一个绩效命中。通过使用 直接向前的硬件,那么您可以避免此编码即使用 输出端口的低4位,并且您只需要几个位操作 操作:较低的四位和掩码:
port_val.&= 0xf0; //清除较低的位
port_val.| = low_nibble & 0x0f; //设置低输出蚕食
op_port =. port_val; //将新数据发送到端口。
对于Arduino操作,性能并不像速度和易于那么重要 编码,它允许用户混合和匹配代码以使其工作 应该知道,在所有魔法下面都有很多魔法 您可以重新编写(或重新连接硬件)以获得更好的性能。
以下示例使用print命令连续输出 更新时间显示每99ms。
#include <LiquidCrystal.h>
#define LCD_RS 5 // Register select
#define LCD_E 4 // Enable
#define LCD_D4 3
#define LCD_D5 2
#define LCD_D6 1
#define LCD_D7 0
// * LCD R/W pin to ground
// * 10K pot:
// * ends to +5V and ground
// * wiper to LCD VO pin (pin 3)
// A Anode Backlight R (~470R) to Vdd
// K kathode to GND, VSS = GND, Vdd = 5V.
// initialize the library with the numbers of the interface pins
液晶 LCD( lcd_rs, lcd_e, lcd_d4, lcd_d5, lcd_d6, lcd_d7);
void 设置() {
lcd.begin(16, 2); // set up the LCD's columns and rows
lcd.clear();
lcd.print("Time:");
lcd.setCursor(0,1);
lcd.print("Time from reset.");
}
long countTime = 0;
long oldTime = 0;
void loop() {
delay(1);
countTime += 1;
if (millis()-oldTime>99) { // update every 99ms
lcd.setCursor(5,0);
lcd.print(countTime,DEC);
oldTime=millis();
}
}
将更新用户定义的字符以提供图形显示 - a 移动栏,表示1/4的递增的尺寸。你可以代表 具有此代码的任何模拟数量..
每个字符都是5个像素宽,并且有16个字符到一个 显示屏上共有16x5 = 80像素。你可以用这个 显示水平条形图的信息。
注意:您可以使用尽可能多的像素,因为栏绘图例程使用 x,y(lcd坐标)开始,然后只有一个数字 以右侧绘制的像素数。
#include <LiquidCrystal.h>
#define LCD_RS 5 // Register select
#define LCD_E 4 // Enable
#define LCD_D4 3
#define LCD_D5 2
#define LCD_D6 1
#define LCD_D7 0
byte cc[8]; // Custom Character
// * LCD R/W pin to ground
// * 10K pot:
// * ends to +5V and ground
// * wiper to LCD VO pin (pin 3)
// A Anode Backlight R (~470R) to Vdd
// K kathode to GND, VSS = GND, Vdd = 5V.
// initialize the library with the numbers of the interface pins
液晶 LCD( lcd_rs, lcd_e, lcd_d4, lcd_d5, lcd_d6, lcd_d7);
// 0 is the full block character
// 1 has left bar filled
// 2 has 2 left bars filled
// ...
// 4 has 4 left bars filled.
void createBarChars(void) {
byte mask = 0x10;
byte current=0;
for (在t cgchar=1; cgchar<=4; cgchar++) {
current |= mask;
mask=mask>>1;
for (在t i=0; i<8; i++) cc[i]=current;
lcd.createChar(cgchar, cc);
}
for (在t i=0; i<8; i++) cc[i]=0x1f; // Create full block.
lcd.createChar(0, cc);
}
void drawBar(byte x, byte y, byte pixels) {
在t i;
byte blocks = pixels / 5; // 5 pixels wide per character.
byte rem = pixels % 5;
for (i=0;i<blocks;i++) {
lcd.setCursor(x+i,y);
lcd.write(byte(0));
}
lcd.setCursor(x+i,y);
if (rem!=0) {
lcd.write(rem);
}
}
void 设置() {
lcd.begin(16, 2); // set up the LCD's columns and rows
lcd.clear();
lcd.print("Time:");
createBarChars();
}
long countTime = 0;
long oldTime = 0;
void loop() {
static 在t idxcg = 0;
delay(1);
countTime += 1;
if (millis()-oldTime>99) { // update every 99ms
lcd.setCursor(5,0);
lcd.print(countTime,DEC);
oldTime=millis();
if ((countTime/250)%80==0) { // Clear Bar Area.
lcd.setCursor(0,1);
lcd.print(" ");
}
drawBar(0,1,(countTime/250)%80); // parameter update is quarter seconds.
}
}
使用ADS1115精度16位ADC进行教程进行低功耗。
arduino.模拟输出:如何创建最精确的PWM模拟输出以及如何创建模拟PWM正弦波。
了解DigitalWrite()的工作原理......现在使用17倍宏宏!
如何使用TCS230(/ TCS3200)彩色检测器芯片并轻松将其添加到您的任何项目中。
使用ADXL345 Acellerometer,您可以检测到16G!您还可以了解如何使用它来点击检测等。
HMC5883L - 如何制作数字罗盘,了解HMC5883L和QMC5883L之间的差异以及它们是否兼容。
新的! Comments
让你说到你刚刚阅读的东西!留下下面的框中的评论。