我的是arduino uno + L293D + 传感器扩展板 连接了HC-05蓝牙模块
当arduino连接USB的时候 通过笔记本串口工具发送“1”, 程序能正常亮灯。
但是当USB拔掉后, L293D独立供电,通过笔记本BlueSoleil千月软件 连接配对蓝牙蓝牙模块后,生成一个串口COM8,我在笔记本上用串口工具打开COM8,发送“1”, arduino程序未能执行。。 应该是串口没收到信息。。
请教各位,怎么弄
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
int val;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
val=Serial.read();
if(val == '1')
{
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
} |