我的开发板是Arduino Leonardo
开发板的0脚是RX,1脚是TX
蓝牙模块的RX接arduino的1脚TX
蓝牙模块的TX接arduino的0脚RX
但是单独使用电池供电以后,数据传不出来。TX灯和RX灯也没有闪烁
请问是哪里出错了?
注:用USB供电,在电脑串口软件中能够看见arduino把超声波传感器发送出来的数据。arduino板子的RX和TX是闪烁的。但是用蓝牙模块接0、1脚以后就不行了。
#include "SR04.h"
#define TRIG_PIN 2
#define ECHO_PIN 3
int led = 13;
SR04 sr04 = SR04(ECHO_PIN,TRIG_PIN);
long a;
void setup() {
Serial.begin(9600);
Serial.println("Example written by Coloz From Arduin.CN");
delay(1000);
pinMode(led, OUTPUT);
}
void loop() {
a=sr04.Distance();
Serial.print(a);
Serial.println("cm");
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second
}
程序用的就是超声波传感器的示范程序
想实现的功能就是传感器测到的数据无线发送到电脑上
加了个LED灯闪烁(用电池供电以后看程序是否运行) |