TextLCD library for controlling various LCD panels based on the HD44780 4-bit interface
Fork of TextLCD by
main.cpp@9:dbeef6223e7a, 2017-07-07 (annotated)
- Committer:
- zhangyx
- Date:
- Fri Jul 07 15:27:16 2017 +0000
- Revision:
- 9:dbeef6223e7a
- Child:
- 10:b5b2b8035bbf
LCD2004 demo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
zhangyx | 9:dbeef6223e7a | 1 | #include "mbed.h" |
zhangyx | 9:dbeef6223e7a | 2 | #include "TextLCD.h" |
zhangyx | 9:dbeef6223e7a | 3 | int main() { |
zhangyx | 9:dbeef6223e7a | 4 | TextLCD lcd(A5, A4, A3, A2, A1, A0, TextLCD::LCD20x4); // rs, e, d4-d7, model |
zhangyx | 9:dbeef6223e7a | 5 | |
zhangyx | 9:dbeef6223e7a | 6 | lcd.printf("Hello World!"); |
zhangyx | 9:dbeef6223e7a | 7 | wait_ms(1000); //等待1秒 |
zhangyx | 9:dbeef6223e7a | 8 | lcd.cls(); //清屏 |
zhangyx | 9:dbeef6223e7a | 9 | |
zhangyx | 9:dbeef6223e7a | 10 | for(int i=0; i<10000; i+=4){ |
zhangyx | 9:dbeef6223e7a | 11 | lcd.locate(0,0); //分别控制起始的列和行,从0开始 |
zhangyx | 9:dbeef6223e7a | 12 | lcd.printf("%d", i); |
zhangyx | 9:dbeef6223e7a | 13 | wait_ms(1000); //等待1秒 |
zhangyx | 9:dbeef6223e7a | 14 | |
zhangyx | 9:dbeef6223e7a | 15 | lcd.locate(0,1); |
zhangyx | 9:dbeef6223e7a | 16 | lcd.printf("%d", i+1); |
zhangyx | 9:dbeef6223e7a | 17 | wait_ms(1000); |
zhangyx | 9:dbeef6223e7a | 18 | |
zhangyx | 9:dbeef6223e7a | 19 | lcd.locate(0,2); |
zhangyx | 9:dbeef6223e7a | 20 | lcd.printf("%d", i+2); |
zhangyx | 9:dbeef6223e7a | 21 | wait_ms(1000); |
zhangyx | 9:dbeef6223e7a | 22 | |
zhangyx | 9:dbeef6223e7a | 23 | lcd.locate(0,3); |
zhangyx | 9:dbeef6223e7a | 24 | lcd.printf("%d", i+3); |
zhangyx | 9:dbeef6223e7a | 25 | wait_ms(1000); |
zhangyx | 9:dbeef6223e7a | 26 | |
zhangyx | 9:dbeef6223e7a | 27 | lcd.cls(); //清屏 |
zhangyx | 9:dbeef6223e7a | 28 | } |
zhangyx | 9:dbeef6223e7a | 29 | |
zhangyx | 9:dbeef6223e7a | 30 | while(1); |
zhangyx | 9:dbeef6223e7a | 31 | } |