“(SKU:RB-05L007)LCD4884液晶搖桿擴(kuò)展板”的版本間的差異
來自ALSROBOT WiKi
(→?例子程序) |
(→?例子程序) |
||
第28行: | 第28行: | ||
* USB數(shù)據(jù)通信線×1 | * USB數(shù)據(jù)通信線×1 | ||
===例子程序=== | ===例子程序=== | ||
? | 程序上傳前需要先[http://pan.baidu.com/s/ | + | 程序上傳前需要先[http://pan.baidu.com/s/1geAGlG3 點(diǎn)此下載]LCD4884 程序使用到的庫文件,將它放到Arduino安裝目錄下的libraries文件夾下<br/> |
? | + | ||
? | + | ||
<pre style='color:blue'> | <pre style='color:blue'> | ||
? | + | /* YourDuinoStarter Example: LCD SHIELD with 'Joystick' button | |
? | + | - WHAT IT DOES Displays on LCD4884, reads button | |
? | + | - SEE the comments after "//" on each line below | |
? | // | + | - CONNECTIONS: |
? | + | - LCD 4884 Shield has all connections | |
? | + | - | |
? | + | NOTE: Start Serial Monitor to see switch voltage values | |
? | + | - V1.00 02/08/2016 | |
? | + | Questions: terry@yourduino.com */ | |
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | // | + | |
? | + | ||
? | / | + | |
? | + | ||
? | + | ||
? | + | ||
? | // | + | /*-----( Import needed libraries )-----*/ |
? | + | #include <LCD4884.h> // UPDATED version 2/16 Yourduino | |
? | + | /*-----( Declare Constants and Pin Numbers )-----*/ | |
? | + | #define LCD_BACKLIGHT_PIN 7 | |
? | + | ||
? | + | /*-----( Declare objects )-----*/ | |
? | + | //None: Included in library | |
? | + | /*-----( Declare Variables )-----*/ | |
? | + | int displayDelay = 1000; | |
? | + | int switchDelay = 100; // Switch scanning delay | |
? | + | int switchVoltage ; // From Analog read of the button resistors | |
? | + | ||
? | + | void setup() /****** SETUP: RUNS ONCE ******/ | |
? | + | ||
? | void setup() | + | |
{ | { | ||
? | // | + | Serial.begin(115200); |
? | // | + | pinMode(LCD_BACKLIGHT_PIN, OUTPUT); |
? | for( | + | lcd.LCD_init(); // creates instance of LCD |
? | + | lcd.LCD_clear(); // blanks the display | |
? | + | for (int a = 0; a < 5; a++) | |
? | + | { | |
+ | digitalWrite(LCD_BACKLIGHT_PIN, LOW); | ||
+ | delay(300); | ||
+ | digitalWrite(LCD_BACKLIGHT_PIN, HIGH); | ||
+ | delay(300); | ||
} | } | ||
? | + | for (int a = 0; a < 6; a++) | |
? | + | { | |
? | + | lcd.LCD_write_string(0, a, "01234567980123", MENU_NORMAL); // ignore MENU_NORMAL for now | |
? | + | delay(displayDelay); | |
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
} | } | ||
? | + | delay(displayDelay); | |
? | + | lcd.LCD_clear(); // blanks the display | |
? | + | delay(500); | |
? | + | // Show the BIG characters (0..9, + - only) | |
? | lcd.LCD_clear(); | + | lcd.LCD_write_string_big(0, 0, "012345", MENU_NORMAL); |
? | + | lcd.LCD_write_string_big(0, 3, "-+-+-+", MENU_NORMAL); | |
? | + | delay(1000); | |
? | + | lcd.LCD_clear(); // now read the joystick using analogRead(0 | |
? | + | ||
? | + | }//--(end setup )--- | |
? | + | ||
? | + | ||
? | + | void loop() /****** LOOP: RUNS CONSTANTLY ******/ | |
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | void | + | |
{ | { | ||
? | + | lcd.LCD_write_string(1, 1, "PUSH A BUTTON", MENU_NORMAL); | |
? | + | switchVoltage = analogRead(0); | |
? | + | Serial.print("Switch analog value = "); | |
? | + | Serial.println(switchDelay); | |
? | + | ||
? | + | if (switchVoltage == 0) | |
? | + | { | |
? | + | lcd.LCD_write_string(2, 2, "LEFT ", MENU_NORMAL); | |
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | lcd.LCD_write_string( | + | |
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
} | } | ||
? | + | else if (switchVoltage > 0 && switchVoltage < 180) | |
? | + | { | |
? | + | lcd.LCD_write_string(2, 2, "PUSH IN", MENU_NORMAL); | |
? | + | delay(switchDelay); | |
? | + | ||
? | + | ||
? | + | ||
? | + | ||
} | } | ||
? | + | else if (switchVoltage > 180 && switchVoltage < 400) | |
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
{ | { | ||
? | + | lcd.LCD_write_string(2, 2, "DOWN ", MENU_NORMAL); | |
? | + | delay(switchDelay); | |
? | + | ||
? | + | ||
} | } | ||
? | if ( | + | else if (switchVoltage > 400 && switchVoltage < 600) |
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
{ | { | ||
? | + | lcd.LCD_write_string(2, 2, "RIGHT", MENU_NORMAL); | |
? | + | delay(switchDelay); | |
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
? | + | ||
} | } | ||
? | } | + | else if (switchVoltage > 600 && switchVoltage < 800) |
? | // | + | { |
? | / | + | lcd.LCD_write_string(2, 2, "UP ", MENU_NORMAL); |
+ | delay(switchDelay); | ||
+ | } | ||
+ | else if (switchVoltage > 800) { | ||
+ | lcd.LCD_write_string(2, 2, "NONE ", MENU_NORMAL); | ||
+ | delay(switchDelay); | ||
+ | } | ||
+ | |||
+ | } //--(end main loop )--- | ||
+ | |||
+ | /*-----( Declare User-written Functions )-----*/ | ||
+ | //NONE | ||
? | + | //*********( THE END )*********** | |
? | + | ||
? | + | ||
? | + | ||
</pre> | </pre> | ||
2016年4月29日 (五) 13:26的版本
目錄 |
產(chǎn)品概述
最新推出的LCD4884 LCD Joystick Shield v2.0 LCD4884液晶屏擴(kuò)展板是哈爾濱奧松機(jī)器人科技有限公司研發(fā)的一款黑白屏液晶擴(kuò)展板。此擴(kuò)展板采用Nokia 5110液晶屏為顯示器件。SPI接口,最大限度的節(jié)省I/O資源。特別添加五向搖桿,方便實(shí)現(xiàn)搭建人機(jī)互動(dòng)接口,剩余的模擬與數(shù)字接口全部用插針引出,便于安裝其它傳感器與模塊。本品適用于各種開發(fā)板和控制器,例如:Arduino控制器、STC單片機(jī)、AVR單片機(jī)等。
規(guī)格參數(shù)
- 產(chǎn)品名稱:LCD4884液晶搖桿擴(kuò)展板
- 產(chǎn)品貨號(hào):RB-05L007
- 工作電壓:DC5V
- 產(chǎn)品類型:Arduino擴(kuò)展板
- 制作工藝:FR4雙面噴錫
- 人性化設(shè)計(jì):具有可人機(jī)互動(dòng)接口“五項(xiàng)搖桿”
- 工作溫度:10℃-30℃
- 重量:28g
- 產(chǎn)品尺寸:69.47mm x 53.34mm x 18mm
- 發(fā)貨清單:LCD4884液晶搖桿擴(kuò)展板×1
- 包裝方式:靜電袋密封
- 選配配件:3PIN傳感器連接線、Arduino 328控制器等
- 板載資源:
- 數(shù)字接口:8個(gè)
- 模擬輸入借口:5個(gè)
- 48×84液晶:1個(gè)
- 無向搖桿按鍵:1個(gè)
- 系統(tǒng)復(fù)位按鍵:1個(gè)
使用方法
使用硬件
- Carduino UNO 控制器 * 1個(gè)
- LCD4884 Joystick Shield ×1
- USB數(shù)據(jù)通信線×1
例子程序
程序上傳前需要先點(diǎn)此下載LCD4884 程序使用到的庫文件,將它放到Arduino安裝目錄下的libraries文件夾下
/* YourDuinoStarter Example: LCD SHIELD with 'Joystick' button - WHAT IT DOES Displays on LCD4884, reads button - SEE the comments after "//" on each line below - CONNECTIONS: - LCD 4884 Shield has all connections - NOTE: Start Serial Monitor to see switch voltage values - V1.00 02/08/2016 Questions: terry@yourduino.com */ /*-----( Import needed libraries )-----*/ #include <LCD4884.h> // UPDATED version 2/16 Yourduino /*-----( Declare Constants and Pin Numbers )-----*/ #define LCD_BACKLIGHT_PIN 7 /*-----( Declare objects )-----*/ //None: Included in library /*-----( Declare Variables )-----*/ int displayDelay = 1000; int switchDelay = 100; // Switch scanning delay int switchVoltage ; // From Analog read of the button resistors void setup() /****** SETUP: RUNS ONCE ******/ { Serial.begin(115200); pinMode(LCD_BACKLIGHT_PIN, OUTPUT); lcd.LCD_init(); // creates instance of LCD lcd.LCD_clear(); // blanks the display for (int a = 0; a < 5; a++) { digitalWrite(LCD_BACKLIGHT_PIN, LOW); delay(300); digitalWrite(LCD_BACKLIGHT_PIN, HIGH); delay(300); } for (int a = 0; a < 6; a++) { lcd.LCD_write_string(0, a, "01234567980123", MENU_NORMAL); // ignore MENU_NORMAL for now delay(displayDelay); } delay(displayDelay); lcd.LCD_clear(); // blanks the display delay(500); // Show the BIG characters (0..9, + - only) lcd.LCD_write_string_big(0, 0, "012345", MENU_NORMAL); lcd.LCD_write_string_big(0, 3, "-+-+-+", MENU_NORMAL); delay(1000); lcd.LCD_clear(); // now read the joystick using analogRead(0 }//--(end setup )--- void loop() /****** LOOP: RUNS CONSTANTLY ******/ { lcd.LCD_write_string(1, 1, "PUSH A BUTTON", MENU_NORMAL); switchVoltage = analogRead(0); Serial.print("Switch analog value = "); Serial.println(switchDelay); if (switchVoltage == 0) { lcd.LCD_write_string(2, 2, "LEFT ", MENU_NORMAL); } else if (switchVoltage > 0 && switchVoltage < 180) { lcd.LCD_write_string(2, 2, "PUSH IN", MENU_NORMAL); delay(switchDelay); } else if (switchVoltage > 180 && switchVoltage < 400) { lcd.LCD_write_string(2, 2, "DOWN ", MENU_NORMAL); delay(switchDelay); } else if (switchVoltage > 400 && switchVoltage < 600) { lcd.LCD_write_string(2, 2, "RIGHT", MENU_NORMAL); delay(switchDelay); } else if (switchVoltage > 600 && switchVoltage < 800) { lcd.LCD_write_string(2, 2, "UP ", MENU_NORMAL); delay(switchDelay); } else if (switchVoltage > 800) { lcd.LCD_write_string(2, 2, "NONE ", MENU_NORMAL); delay(switchDelay); } } //--(end main loop )--- /*-----( Declare User-written Functions )-----*/ //NONE //*********( THE END )***********
程序效果
視頻演示
產(chǎn)品相關(guān)推薦
購買地址
周邊產(chǎn)品推薦
1602液晶顯示器 藍(lán)白屏
Arduino IIC/I2C LCD1602 字符液晶顯示器
相關(guān)問題解答
LCD4884液晶搖桿擴(kuò)展板顯示應(yīng)用
關(guān)于arduino的LCD4884的使用