RadioLib/examples/HC05/HC05_Basic/HC05_Basic.ino

35 wiersze
812 B
Arduino
Czysty Zwykły widok Historia

2018-07-03 10:01:37 +00:00
/*
2019-02-08 14:58:29 +00:00
RadioLib HC05 Example
2018-07-23 10:43:12 +00:00
This example sends data using HC05 Bluetooth module.
HC05 works exactly like a Serial line, data are sent to the paired device.
The default pairing code for HC05 is 1234.
*/
2018-07-03 10:01:37 +00:00
// include the library
2019-02-08 14:58:29 +00:00
#include <RadioLib.h>
2018-07-03 10:01:37 +00:00
// HC05 module is in slot A on the shield
2019-02-08 14:58:29 +00:00
HC05 bluetooth = RadioShield.ModuleA;
2018-07-03 10:01:37 +00:00
void setup() {
Serial.begin(9600);
2018-07-11 15:41:01 +00:00
// initialize HC05
// baudrate: 9600 baud
2018-07-03 10:01:37 +00:00
bluetooth.begin(9600);
}
void loop() {
// HC05 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:12 +00:00
while (Serial.available() > 0) {
2018-07-03 10:01:37 +00:00
bluetooth.write(Serial.read());
}
2018-07-23 10:43:12 +00:00
2018-07-16 17:13:24 +00:00
// read data incoming from Bluetooth and write them to Serial port
2018-07-23 10:43:12 +00:00
while (bluetooth.available() > 0) {
2018-07-16 17:13:24 +00:00
Serial.write(bluetooth.read());
}
2018-07-03 10:01:37 +00:00
}