arduinoUno连接发射模块与接收模块跟显示屏说明
1.?Uno板連接接收模塊與發射模塊
1.1接線說明
接收模塊 ??Uno板
GND ------------GND接地線
VCC -------------5V接電源
數據引腳------11引腳(此例子接法)
?
?
發射模塊 ??Uno板
GND ------------GND接地線
VCC -------------5V接電源
數據引腳------12引腳(此例子接法)
?
1.2測試代碼
接收模塊代碼:
| #include <VirtualWire.h> #undef int #undef abs #undef double #undef float #undef round ? ?byte buf[VW_MAX_MESSAGE_LEN]; ?byte buflen = VW_MAX_MESSAGE_LEN; void setup() { ???Serial.begin(9600); ?// Debugging only ???Serial.println("setup"); ???Serial.println("Receiver..."); ???// Initialise the IO and ISR ???vw_set_ptt_inverted(true); // Required for DR3100 ???vw_setup(2000); ??// Bits per sec ???vw_rx_start(); ??????// Start the receiver PLL running } void loop() { ? ???if (vw_get_message(buf, &buflen))//Non-blocking ??{ ???int i; ???digitalWrite(12, true); ?//Flash a light to show received good message ???Serial.print("Got: "); //Message with a good checksum received, dump it. ???for (i = 0; i < buflen; i++) ??{ ???Serial.print(buf[i], HEX); ???Serial.print(" "); ????} ???Serial.println(""); ???digitalWrite(12, false); ???} ???} ? |
?
?
發射模塊代碼:
| #include <VirtualWire.h> #undef int #undef abs #undef double #undef float #undef round void setup() { ???Serial.begin(9600); ???// Debugging only ???Serial.println("setup"); ???Serial.println("Transmmiter..."); ???// Initialise the IO and ISR ???vw_set_ptt_inverted(true); // Required for DR3100 ???vw_setup(2000); ??// Bits per sec } void loop() { ???const char *msg = "hello"; ???digitalWrite(13, true); // Flash a light to show transmitting ???vw_send((uint8_t *)msg, strlen(msg)); ???vw_wait_tx(); // Wait until the whole message is gone ???digitalWrite(13, false); ???delay(200); ???} ? |
?
?
2.?Uno板連接顯示器
2.1 接線說明
?
2.2 測試代碼
2.2.1英文顯示屏測試代碼
| //LingShun lab ? #include <Wire.h> ?? #include <LiquidCrystal_I2C.h> //引用I2C庫 ? ?? //設置LCD1602設備地址,這里的地址是0x3F,一般是0x20,或者0x27,具體看模塊手冊 ? LiquidCrystal_I2C lcd(0x3F,16,2); ??? ? ?? void setup() ? { ? ??lcd.init(); ?????????????????// 初始化LCD ? ??lcd.backlight(); ????????????//設置LCD背景等亮 ? } ? ?? void loop() ? { ??lcd.setCursor(0,0); ???????????????//設置顯示指針 ? ??lcd.print("Hello Wzx!!!"); ????//輸出字符到LCD1602上 ??int ButtonState = digitalRead(0); //設置變量存儲讀到的狀態值 ? ??//lcd.clear(); ??delay(1000); ? } ? |
?
?
2.2.2中文顯示屏測試代碼
| #include <RSCG12864B.h>//引用庫文件 void setup() { void loop() { ? |
?
總結
以上是生活随笔為你收集整理的arduinoUno连接发射模块与接收模块跟显示屏说明的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 初中计算机应用教案,初中信息技术教学设计
- 下一篇: 船期查询