“SKU:RB-02S159 模擬鍵盤模塊”的版本間的差異
來自ALSROBOT WiKi
(→?產(chǎn)品概述) |
(→?產(chǎn)品參數(shù)) |
||
第5行: | 第5行: | ||
==產(chǎn)品參數(shù)== | ==產(chǎn)品參數(shù)== | ||
===基本參數(shù)=== | ===基本參數(shù)=== | ||
? | + | #品名:模擬按鍵模塊 | |
+ | #貨號(hào):RB-02S159 | ||
+ | #尺寸:55*40mm | ||
+ | #固定孔:M3*4 | ||
===電氣性能=== | ===電氣性能=== | ||
+ | 1.工作電壓:3.3V~5V<br/> | ||
+ | 2.工作溫度限值:-20℃ ~ +70℃<br/> | ||
+ | 3.信號(hào)類型:模擬信號(hào)<br/> | ||
+ | 4.接口類型:3P 防插反接口<br/> | ||
+ | 5.工作電流:小于等于20mA,5V 供電下<br/> | ||
+ | 6.按鍵及指示燈:S1 ~ S5 五個(gè)按鍵旁分別配有指示燈,按下時(shí)亮起<br/> | ||
+ | 7.按鍵模擬值:<br/> | ||
+ | :S1=380±40 | ||
+ | :S2=470±40 | ||
+ | :S3=560±40 | ||
+ | :S4=680±40 | ||
+ | :S5=840±40 | ||
+ | 8.引腳定義:<br/> | ||
+ | :+:電源正極 | ||
+ | :-:電源負(fù)極 | ||
+ | :S:信號(hào) | ||
==使用方法== | ==使用方法== |
2018年9月12日 (三) 16:58的版本
目錄 |
產(chǎn)品概述
奧松機(jī)器人新推出的模擬鍵盤模塊,我們?cè)谠O(shè)計(jì)按鍵輸入電路時(shí),采用獨(dú)立IO連接按鍵或者矩陣連接的方式,矩陣連接相對(duì)于獨(dú)立連接的方式來說占用IO相對(duì)較少,但有沒有一種更好的方式呢,模擬鍵盤模塊就很好的解決了這個(gè)問題,它能讓你用一個(gè)模擬IO口,實(shí)現(xiàn)五個(gè)按鍵狀態(tài)的讀取,真正實(shí)現(xiàn)了電路的簡(jiǎn)化,并且在按下按鍵時(shí),按鍵旁的LED會(huì)隨之亮起。
產(chǎn)品參數(shù)
基本參數(shù)
- 品名:模擬按鍵模塊
- 貨號(hào):RB-02S159
- 尺寸:55*40mm
- 固定孔:M3*4
電氣性能
1.工作電壓:3.3V~5V
2.工作溫度限值:-20℃ ~ +70℃
3.信號(hào)類型:模擬信號(hào)
4.接口類型:3P 防插反接口
5.工作電流:小于等于20mA,5V 供電下
6.按鍵及指示燈:S1 ~ S5 五個(gè)按鍵旁分別配有指示燈,按下時(shí)亮起
7.按鍵模擬值:
- S1=380±40
- S2=470±40
- S3=560±40
- S4=680±40
- S5=840±40
8.引腳定義:
- +:電源正極
- -:電源負(fù)極
- S:信號(hào)
使用方法
example1_Arduino
- 主要硬件
- Arduino UNO 控制器
- 傳感器擴(kuò)展板 V5.0
- 模擬按鍵模塊
- 單頭防插反 3P 傳感器連接線
- USB 數(shù)據(jù)線
- 硬件連接
- 示例程序
int adc_key_val[5] ={400,470,560,700,900 }; int NUM_KEYS = 5; int adc_key_in; int key=-1; int oldkey=-1; void setup() { pinMode(13, OUTPUT); //we'll use the debug LED to output a heartbeat Serial.begin(9600); // 9600 bps } void loop() { adc_key_in = analogRead(0); // read the value from the sensor digitalWrite(13,LOW); key = get_key(adc_key_in); // convert into key press //Serial.println(adc_key_in); if (key != oldkey) // if keypress is detected { delay(50); // wait for debounce time adc_key_in = analogRead(0); // read the value from the sensor key = get_key(adc_key_in); // convert into key press if (key != oldkey) { oldkey = key; if (key >=0){ digitalWrite(13,HIGH); switch(key) { case 0:Serial.println("S1 OK"); break; case 1:Serial.println("S2 OK"); break; case 2:Serial.println("S3 OK"); break; case 3:Serial.println("S4 OK"); break; case 4:Serial.println("S5 OK"); break; } } } } delay(100); } // Convert ADC value to key number int get_key(unsigned int input) { int k; for (k = 0; k < NUM_KEYS; k++) { if (input < adc_key_val[k]) { return k; } } if (k >= NUM_KEYS)k = -1; // No valid key pressed return k; }
- 程序效果
example2_Arduino
- 主要硬件
- Arduino UNO 控制器
- 傳感器擴(kuò)展板 V5.0
- 模擬按鍵模塊
- 單頭防插反 3P 傳感器連接線
- USB 數(shù)據(jù)線
- 全彩 LED 發(fā)光模塊
- 硬件連接
- 示例程序
#include <MeRGBLed.h> MeRGBLed led(PORT_3); int adc_key_val[5] ={400,470,560,700,900 }; int NUM_KEYS = 5; int adc_key_in; int key=-1; int oldkey=-1; int get_key(unsigned int input) { int k; for (k = 0; k < NUM_KEYS; k++) { if (input < adc_key_val[k]) { return k; } } if (k >= NUM_KEYS)k = -1; // No valid key pressed return k; } void color_r() { led.setColor(255, 0, 0); led.show(); } void color_g() { led.setColor(0, 255, 0); led.show(); } void color_b() { led.setColor(0, 0, 255); led.show(); } void color_y() { led.setColor(255, 255, 0); led.show(); } void color_w() { led.setColor(255, 250, 250); led.show(); } void setup() { pinMode(13, OUTPUT); //we'll use the debug LED to output a heartbeat Serial.begin(9600); // 9600 bps } void loop() { adc_key_in = analogRead(0); // read the value from the sensor digitalWrite(13,LOW); key = get_key(adc_key_in); // convert into key press if (key != oldkey) // if keypress is detected { delay(50); // wait for debounce time adc_key_in = analogRead(0); // read the value from the sensor key = get_key(adc_key_in); // convert into key press if (key != oldkey) { oldkey = key; if (key >=0) { if(key==0) { color_y(); } if(key==1) { color_b(); } if(key==2) { color_r(); } if(key==3) { color_g(); } if(key==4) { color_w(); } } } } delay(100); }
- 程序效果
按下相應(yīng)按鍵,全彩LED會(huì)顯示與按鍵帽相同的顏色。
example3_Arduino
- 主要硬件
- Arduino UNO 控制器
- 傳感器擴(kuò)展板 V5.0
- 模擬按鍵模塊
- 單頭防插反 3P 傳感器連接線
- USB 數(shù)據(jù)線
- 4WD 移動(dòng)平臺(tái)
- APC220 無線數(shù)傳模塊
- MotorDriver Shield 電機(jī)驅(qū)動(dòng)板
- 示例程序
接收端
發(fā)射端
- 程序效果
- S3 -- 前進(jìn)
- S2 -- 后退
- S4 -- 左轉(zhuǎn)
- S1 -- 右轉(zhuǎn)
- S5 -- 停止
相關(guān)資料
- 模擬按鍵示例程序下載
鏈接:https://pan.baidu.com/s/1QReHaInd2T2wP7-yzmiSwQ 密碼:g914
- 產(chǎn)品購(gòu)買鏈接:http://lifestyle201.com/goods-873.html