极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9920|回复: 2

求助关于蓝牙连接小车

[复制链接]
发表于 2014-7-31 19:58:39 | 显示全部楼层 |阅读模式
我的是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
  }
}
回复

使用道具 举报

发表于 2014-8-1 14:26:07 | 显示全部楼层
看看笔记本的蓝牙模块和小车的蓝牙模块是否握手成功(两边模块上的指示灯常亮),你需要检查一下蓝牙模块的设置。一是一主一从,二是波特率一致。
回复 支持 反对

使用道具 举报

发表于 2014-8-1 15:02:22 | 显示全部楼层
void loop() {
while(Serial.available())//这个建议加上  
{
val=Serial.read();
   if(val == '1')
   
   digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
   delay(1000);
这缺了else               // wait for a second
   digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
   delay(1000);               // wait for a second
   
}
}具体可以参见我的帖子http://www.geek-workshop.com/thread-10487-1-1.html
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-14 08:56 , Processed in 0.073509 second(s), 20 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表