I have a device connected to pins RX and TX of my Arduino UNO and I need more pins RX and TX to send data via bluetooth to Android. I plan to use two pins SoftwareSerial to convert into RX and TX for use with the Bluetooth module. I suppose it's possible. I have read on the subject but most I've found is to make the connection and send data from Android to Arduino. I think with me it would be possible Amarino library. If so far everything I have planned well, I have a big doubt. How do I pass the data received by the Arduino RX pin of the device that I have connected to the TX pin of the bluetooth to send to Android? I guess I'll have to send from arduino and program it from the IDE. I hope your help, thanks!
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Sounds like you just want the code to transfer between Serial Ports
void loop() {
...
while (Serial1.available()) {
Serial2.write((uint8_t ) Serial1.read());
}
while (Serial2.available()) {
Serial1.write((uint8_t ) Serial2.read());
}
...
Which simply reads a byte from Serial1 if available and sends it to Serial2 until empty and vice versa. Where Serial1 and Serial2 can be replaced with your SoftwareSerial Objects. Keep in mind High through but could saturate as this example is not limiting. but typical Serial ports should be fine.