Sync Between Devices.
This commit is contained in:
38
Homework/Homework4/Bluetooth/Bluetooth.ino
Normal file
38
Homework/Homework4/Bluetooth/Bluetooth.ino
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "SoftwareSerial.h"
|
||||
|
||||
const byte rx_connected = 11;
|
||||
const byte tx_connected = 10;
|
||||
|
||||
SoftwareSerial soft_serial(tx_connected, rx_connected);
|
||||
|
||||
void setup() {
|
||||
pinMode(tx_connected, INPUT);
|
||||
pinMode(rx_connected, OUTPUT);
|
||||
Serial.begin(9600);
|
||||
soft_serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (Serial.available()) {
|
||||
char ch = Serial.read();
|
||||
Serial.print(ch);
|
||||
soft_serial.print(ch);
|
||||
}
|
||||
if (soft_serial.available()) {
|
||||
char ch = soft_serial.read();
|
||||
Serial.print(ch);
|
||||
soft_serial.print(ch);
|
||||
}
|
||||
Serial.println("A loop");
|
||||
// Serial.println("A loop");
|
||||
// if (soft_serial.availableForWrite()) {
|
||||
// Serial.println("Available");
|
||||
// }
|
||||
// else {
|
||||
// Serial.println("Unavailable");
|
||||
// }
|
||||
// if (Serial.availableForWrite()) {
|
||||
// Serial.println("Can Write");
|
||||
// }
|
||||
delay(1000);
|
||||
}
|
||||
Reference in New Issue
Block a user