DF機器人藍牙模塊如何連接到Arduino以便Arduino可以與之通信。DF機器人藍牙模塊與Arduino的接口
我設法讓燈閃爍在模塊上,它似乎可以配對,但是當我運行串行監視器併發送一個字母(說'H')這應該打開一個燈我得到Java錯誤:
java.io.IOException: Bad file descriptor in nativeDrain
at gnu.io.RXTXPort.nativeDrain(Native Method)
at gnu.io.RXTXPort$SerialOutputStream.flush(RXTXPort.java:1201)
at processing.app.Serial.write(Serial.java:470)
at processing.app.Serial.write(Serial.java:492)
at processing.app.SerialMonitor.send(SerialMonitor.java:128)
at processing.app.SerialMonitor.access$100(SerialMonitor.java:29)
at processing.app.SerialMonitor$4.actionPerformed(SerialMonitor.java:82)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
我檢查了線路和我有RXD要去RX在董事會和TXD到TX(引腳1)(引腳0),其餘有線了,但同樣仍然沒有運氣。什麼可能是這個問題?
這是我對Arduino的代碼:
int ledpin = 13;
char val;
void setup() {
pinMode(ledpin, OUTPUT); // pin 48 (on-board LED) as OUTPUT
Serial.begin(9600); // start serial communication at 9600bps
}
void loop() {
if(Serial.available()) { // if data is available to read
val = Serial.read(); // read it and store it in 'val'
}
if(val == 'H') { // if 'H' was received
digitalWrite(ledpin, HIGH); // turn ON the LED
} else {
digitalWrite(ledpin, LOW); // otherwise turn it OFF
}
delay(100); // wait 100ms for next reading
}
您是否能夠直接將Arduino連接到串行端口並使通信正常工作(即沒有混合藍牙模塊)? – 2009-09-02 15:56:55
是的,它似乎只是藍牙不喜歡的IDE連接庫liburi – 2009-09-03 09:00:38
請你詳細介紹一下組件(Arduino IDE,串口,藍牙模塊,Arduino等)以及它們之間的通信機制(串口,藍牙,等等。)?特別是我不清楚如何將數據發送到串行端口轉換爲藍牙信號並由模塊接收。 – 2009-09-03 09:39:01