Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of TextLCD by
Revision 9:dbeef6223e7a, committed 2017-07-07
- Comitter:
- zhangyx
- Date:
- Fri Jul 07 15:27:16 2017 +0000
- Parent:
- 8:308d188a2d3a
- Child:
- 10:b5b2b8035bbf
- Commit message:
- LCD2004 demo
Changed in this revision
--- a/TextLCD.cpp Thu Jan 02 21:07:01 2014 +0000
+++ b/TextLCD.cpp Fri Jul 07 15:27:16 2017 +0000
@@ -25,7 +25,7 @@
TextLCD::TextLCD(PinName rs, PinName e, PinName d4, PinName d5,
PinName d6, PinName d7, LCDType type) : _rs(rs),
- _e(e), _d(d4, d5, d6, d7),
+ _e(e,1), _d(d4, d5, d6, d7),
_type(type) {
_e = 1;
@@ -39,12 +39,13 @@
wait(0.00164); // this command takes 1.64ms, so wait for it
}
writeByte(0x2); // 4-bit mode
- wait(0.000040f); // most instructions take 40us
+ wait(0.00164); // 1.64ms
writeCommand(0x28); // Function set 001 BW N F - -
writeCommand(0x0C);
writeCommand(0x6); // Cursor Direction and Display Shift : 0000 01 CD S (CD 0-left, 1-right S(hift) 0-no, 1-yes
cls();
+
}
void TextLCD::character(int column, int row, int c) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Jul 07 15:27:16 2017 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+#include "TextLCD.h"
+int main() {
+ TextLCD lcd(A5, A4, A3, A2, A1, A0, TextLCD::LCD20x4); // rs, e, d4-d7, model
+
+ lcd.printf("Hello World!");
+ wait_ms(1000); //等待1秒
+ lcd.cls(); //清屏
+
+ for(int i=0; i<10000; i+=4){
+ lcd.locate(0,0); //分别控制起始的列和行,从0开始
+ lcd.printf("%d", i);
+ wait_ms(1000); //等待1秒
+
+ lcd.locate(0,1);
+ lcd.printf("%d", i+1);
+ wait_ms(1000);
+
+ lcd.locate(0,2);
+ lcd.printf("%d", i+2);
+ wait_ms(1000);
+
+ lcd.locate(0,3);
+ lcd.printf("%d", i+3);
+ wait_ms(1000);
+
+ lcd.cls(); //清屏
+ }
+
+ while(1);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jul 07 15:27:16 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/64910690c574 \ No newline at end of file
