问题描述
我有点坚持在这里。我有一个HC-05蓝牙模块 - 从ebay-和我测试它以确定它的工作原理。我已经上传以下草图到芯片:
////////////////////////////////////// //////////////////////////////////////////////混音BY:TECHBITAR(海济比塔尔)
//许可:公域
//日期:2012年5月2日
//联系方式:techbitar在Gmail的点com焦炭INBYTE;
INT LED = 13; //引脚13 LED无效设置(){
Serial.begin(9600);
pinMode(LED,OUTPUT);
}空隙环(){
Serial.println(preSS 1把Arduino的13脚LED,或者为0关闭该功能:);
而(Serial.available()!); //只要待在这儿COM端口为空
INBYTE = Serial.read(); //读取下一个可用字节
如果(INBYTE =='0')digitalWrite(LED,低); //如果它是一个0(零)TUN LED熄灭
如果(INBYTE =='1')digitalWrite(LED,高); //如果它是一个1(一)LED灯亮
延迟(50);
}
我已经使用在Android上三个不同的蓝牙终端,以及对WIN7的TeraTerm终端测试,如果blutooth模块成功进行通信。无论出于何种原因,所有4个接收行 preSS 1把Arduino的13脚LED,或者为0关闭该功能:
但是当我在终端中输入1其发送到模块,LED不亮。
请注意:
而LED工程
我很肯定,我适当地连接一切
我的RX和TX串行线路必须努力否则我将无法上传草图。
是否有可能使HC-05不工作,无法接收信息?我能做些什么,否则测试?
非常感谢!
感谢@SunGa的环回的想法。它的工作,所以我可以证实蓝牙模块处于良好的健康状况。通过其他论坛阅读,试图理解为什么引脚0
无法接收蓝牙模块,我发现,这是一个常见的问题发送的串行信号。它使原来,因为RX和TX是硬连接到USB转TTL转换器芯片上的电路板,有时引脚0的状态
和引脚1
获得卡住,不能被恰当地使用(这是不幸的!和工程差IMO)。
我是能够成功地发送和通过利用 SoftwareSerial
库接收数据
和重映射 10引脚和11
来接收和发送。
这是说,如果一个ATMEGA芯片被用作一个独立的微控制器(如DIYduino),那么引脚0和1
可用于通信的蓝牙模块
希望这可以帮助别人谁面临着同样的问题。
I'm kind of stuck here. I have a HC-05 Bluetooth module - from ebay- and i'm testing it to make certain it works. I have uploaded the following sketch to the chip:
//////////////////////////////////////////////////////////////////////////////////
// REMIXED BY: TECHBITAR (HAZIM BITAR)
// LICENSE: PUBLIC DOMAIN
// DATE: MAY 2, 2012
// CONTACT: techbitar at gmail dot com
char INBYTE;
int LED = 13; // LED on pin 13
void setup() {
Serial.begin(9600);
pinMode(LED, OUTPUT);
}
void loop() {
Serial.println("Press 1 to turn Arduino pin 13 LED ON or 0 to turn it OFF:");
while (!Serial.available()); // stay here so long as COM port is empty
INBYTE = Serial.read(); // read next available byte
if( INBYTE == '0' ) digitalWrite(LED, LOW); // if it's a 0 (zero) tun LED off
if( INBYTE == '1' ) digitalWrite(LED, HIGH); // if it's a 1 (one) turn LED on
delay(50);
}
I have used three different bluetooth terminal on android as well as the TeraTerm terminal on WIN7 to test if the blutooth module successfully communicates. For whatever reason, all 4 receive the line Press 1 to turn Arduino pin 13 LED ON or 0 to turn it OFF:
but when I enter 1 in the terminals and send it to the module, the LED does not turn on.
Note: The LED worksI'm affirmative I've wired everything appropriatelyMy RX and TX serial lines must work otherwise I would not be able to upload the sketch.
Is it possible that the HC-05 is not working and is unable to receive information? What can I do to test otherwise?
Thanks alot!
Thanks @SunGa for the loop-back idea. It worked, so I can confirm the Bluetooth module is in good health. Reading through other forums to try to understand why pin 0
could not receive the serial signal sent by the Bluetooth module I discovered that this was a common issue. It so turns out that since RX and TX are hard wired to the USB to TTL converter chip on the board, sometimes the state of Pin 0
and Pin 1
get "stuck" and they can't be used appropriately ( which is unfortunate! and poor engineering imo).
I was able to successfully send and receive data by making use of the SoftwareSerial
libraryand remapping Pins 10 and 11
to RX and TX.
That said, If an AtMega chip was used as a stand alone microcontroller (e.g. DIYduino) then Pins 0 and 1
could be used to communicate to the Bluetooth module!
Hope this can help others who face the same issue
这篇关于在Arduino的+调试HC-05蓝牙模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!