Hello!
Im trying to connect two arduinos using bluetooth but i have no idea how to accomplish this. So far i've made an android application that can communicate with my arduino application.
This is the arduino code:
/* Include the software serial port library */
#include <SoftwareSerial.h>
char incomingByte; // incoming data
int LED = 8; // LED pin
int tx = 2; // TX pin
int rx = 3; // RX pin
SoftwareSerial BluetoothSerial(tx, rx);
void setup() {
Serial.begin(9600); // initialization
pinMode(LED, OUTPUT);
BluetoothSerial.begin(9600);
Serial.println("Press 1 to LED ON or 0 to LED OFF...");
}
void loop() {
if (BluetoothSerial.available()){
Serial.println("asd");
digitalWrite(LED, HIGH);
incomingByte = BluetoothSerial.read();
Serial.println((char)incomingByte);
//Serial.println(BluetoothSerial.read());
if(incomingByte == '0') {
digitalWrite(LED, LOW); // if 1, switch LED Off
Serial.println("LED OFF. Press 1 to LED ON!"); // print message
}
if(incomingByte == '1') {
digitalWrite(LED, HIGH); // if 0, switch LED on
Serial.println("LED ON. Press 0 to LED OFF!");
}
}
}
I got two Arduino UNOs and two JY-MCU bluetooth modules.
Is there a way to send a message to one arduino and then receive the message on the other UNO and for example, light a LED?
Thanks in advance!