|
|

楼主 |
发表于 2013-10-19 00:29:47
|
显示全部楼层
本帖最后由 kenlittle 于 2013-10-19 00:30 编辑
终于搞定了,NND,看了些官方的代码资料,其实还是串口的问题,官方定义了软口
代码如下:
- #include <SoftwareSerial.h>
- SoftwareSerial mySerial(10, 11); // RX, TX
- void setup()
- {
- // Open serial communications and wait for port to open:
- Serial.begin(9600);
- pinMode(9, OUTPUT);
- while (!Serial) {
- ; // wait for serial port to connect. Needed for Leonardo only
- }
- // set the data rate for the SoftwareSerial port
- mySerial.begin(9600);
- }
- void loop() // run over and over
- {
- if (mySerial.available()){//Resp the data
- int val = mySerial.read();
- if(val == 'T')
- {
- mySerial.write('R');
- digitalWrite(9,HIGH);
- delay(2000);
- digitalWrite(9,LOW);
- }
- }
- if (Serial.available()){//Send the data
- mySerial.write(Serial.read());
- }
- }
复制代码
这个破问题折腾我好几天了。。。终于搞定了,希望此贴能给同样问题的人一个提示
不行,睡觉先了{:soso_e125:} |
|