Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //master
- #include <SoftwareSerial.h>
- SoftwareSerial BTserial(6, 7); // RX | TX
- #define __BAUD 38400
- void setup(){
- BTserial.begin(__BAUD);
- delay(1000);
- Serial.println("ready...");
- }
- void loop() {
- BTserial.write('a');
- delay(1000);
- BTserial.write('s');
- delay(1000);
- }
- //slave
- #include <SoftwareSerial.h>
- SoftwareSerial BTserial(6, 7); // RX | TX
- #define __BAUD 38400
- void setup(){
- Serial.begin(__BAUD);
- BTserial.begin(__BAUD);
- delay(1000);
- Serial.println("ready...");
- pinMode(10, OUTPUT);
- }
- void loop() {
- if (BTserial.available()) {
- Serial.write("comunicazione");
- char c = BTserial.read();
- Serial.write(c);
- if (c == 'a') {
- digitalWrite(10, HIGH);
- }
- if (c == 's') {
- digitalWrite(10, LOW);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement