Arduino论坛
直播中

jincheni227

8年用户 134经验值
擅长:可编程逻辑 MEMS/传感技术 测量仪表 嵌入式技术 模拟技术 处理器/DSP 接口/总线/驱动 控制/MCU
私信 关注
[经验]

[Arduino经验] 【Landzo C1试用体验】小车未到,先上传一个自造的字库驱动1602显示

本帖最后由 jincheni227 于 2016-6-9 14:15 编辑

首先感谢电子发烧友论坛给我的这次【Landzo C1试用体验】,小车还在邮寄的路上,在期待的同时,先用landzo c1的核心控制板arduino驱动1602,等小车到了后可以增加显示模块。
本帖可以看到:
1.用arduino驱动1602显示器效果图;
2.学习arduino中的liquidcrystal显示库函数应用
3.在1602中显示英文及数字;
4.增加1602字形库中没有的文字;
IMG_20160609_123305.jpg

1602有4线和8线接法,这里选取8线,对于c51单片机驱动在编程上有所区别,但对于arduino开发板来说4线和8线在编程上几乎一致,仅需要修改引脚的接线方式;


上传实例代码:
/*
  LiquidCrystal Library - Custom Characters

Demonstrates how to add custom characters on an LCD  display.
The LiquidCrystal library works with all LCD displays that are
compatible with the  Hitachi HD44780 driver. There are many of
them out there, and you can usually tell them by the 16-pin interface.

This sketch prints "I Arduino!" and a little dancing man
to the LCD.

  The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* 10K potentiometer:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
* 10K poterntiometer on pin A0

created 21 Mar 2011
by Tom Igoe
modified 11 Nov 2013
by Scott Fitzgerald

Based on Adafruit's example at
https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde

This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystal

Also useful:
http://icontexto.com/charactercreator/

*/

// include the library code:
#include

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12,11,2,3,4,5,6,7,8,9,10);

// make some custom characters:
byte heart[8] = {
  0b00000,
  0b01010,
  0b11111,
  0b11111,
  0b11111,
  0b01110,
  0b00100,
  0b00000
};

byte smiley[8] = {
  0b00100,
  0b01110,
  0b00100,
  0b11111,
  0b01100,
  0b01110,
  0b11100,
  0b10111
};

byte frownie[8] = {
  0b00000,
  0b00000,
  0b01010,
  0b01010,
  0b00100,
  0b01010,
  0b01010,
  0b00000
};

byte ARMsDown[8] = {
  0b00100,
  0b01010,
  0b00100,
  0b00100,
  0b01110,
  0b10101,
  0b00100,
  0b01010
};

byte armsUp[8] = {
  0b00100,
  0b01010,
  0b00100,
  0b10101,
  0b01110,
  0b00100,
  0b00100,
  0b01010
};

void setup() {
  // initialize LCD and set up the number of columns and rows:
  lcd.begin(16, 2);

  // create a new character
  lcd.createChar(0, heart);
  // create a new character
  lcd.createChar(1, smiley);
  // create a new character
  lcd.createChar(2, frownie);
  // create a new character
  lcd.createChar(3, armsDown);
  // create a new character
  lcd.createChar(4, armsUp);
  lcd.clear();
  lcd.setCursor(0,0);
  // Print a message to the lcd.
  lcd.print("I ");
   lcd.write(byte(0));
  // when calling lcd.write() '0' must be cast as a byte
  lcd.print(" Arduino! ");

  lcd.write(byte(1));
  lcd.write(byte(2));

}

void loop() {
  // read the potentiometer on A0:

  lcd.setCursor(1, 1);
  // draw the little man, arms down:
  lcd.write(3);
  delay(200);
  lcd.setCursor(1, 1);
  // draw him arms up:
  lcd.write(4);
  delay(200);
  lcd.print(" 2016-06-09");
}

  • IMG_20160609_122540.jpg
  • IMG_20160609_121543.jpg
  • 未命名.JPG
  • IMG_20160609_121519.jpg

更多回帖

发帖
×
20
完善资料,
赚取积分