RadioLib/examples/JDY08/JDY08_Basic/JDY08_Basic.ino

43 wiersze
953 B
Arduino
Czysty Zwykły widok Historia

2018-07-14 14:12:19 +00:00
/*
2019-02-08 14:58:29 +00:00
RadioLib JDY08 Example
2018-07-23 10:43:25 +00:00
This example sends data using JDY08 Bluetooth module.
2019-06-02 13:02:26 +00:00
JDY08 works exactly like a Serial line, data are sent to the paired device.
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
2018-07-23 10:43:25 +00:00
*/
2018-07-14 14:12:19 +00:00
// include the library
2019-02-08 14:58:29 +00:00
#include <RadioLib.h>
2018-07-14 14:12:19 +00:00
2019-06-02 13:02:26 +00:00
// JDY08 has the following connections:
// TX pin: 9
// RX pin: 8
JDY08 ble = new Module(9, 8);
// or using RadioShield
// https://github.com/jgromes/RadioShield
//JDY08 ble = RadioShield.ModuleA;
2018-07-14 14:12:19 +00:00
void setup() {
Serial.begin(9600);
// initialize JDY08
// baudrate: 9600 baud
ble.begin(9600);
}
void loop() {
// JDY08 supports all methods of the Serial class
2018-07-16 17:13:24 +00:00
// read data incoming from Serial port and write them to Bluetooth
2018-07-23 10:43:25 +00:00
while (Serial.available() > 0) {
2018-09-22 15:49:23 +00:00
ble.write(Serial.read());
2018-07-14 14:12:19 +00:00
}
2018-07-23 10:43:25 +00:00
2018-07-16 17:13:24 +00:00
// read data incoming from Bluetooth and write them to Serial port
2018-09-22 16:49:27 +00:00
while (ble.available() > 0) {
2018-09-22 15:49:23 +00:00
Serial.write(ble.read());
2018-07-14 14:12:19 +00:00
}
}