Making two arduinos talk together via Bluesmurf
i have been struggling problem times now.
i have bluesmurf (silver) modules, , want able send numbers 1 arduino other one. have been searching long , didnt find soloution.
what have right now, 2 bluesmurf connected , show green light when both online
master
slave
anyone knew solution ?
i have bluesmurf (silver) modules, , want able send numbers 1 arduino other one. have been searching long , didnt find soloution.
what have right now, 2 bluesmurf connected , show green light when both online
master
code: [select]
/*
* bluetooh basic: led on off - avishkar
* coder - mayoogh girish
* website - http://bit.do/avishkar
* download app : https://github.com/mayoogh/arduino-bluetooth-basic
* program lets control led on pin 13 of arduino using bluetooth module
*/
char data = 0; //variable storing received data
void setup()
{
serial.begin(9600); //sets baud serial data transmission
pinmode(13, output); //sets digital pin 13 output pin
}
void loop()
{
if(serial.available() > 0) // send data when receive data:
{
data = serial.read(); //read incoming data & store data
serial.println(data); //print value inside data in serial monitor
serial.println("\n");
if(data == '1') { // checks whether value of data equal 1
digitalwrite(13, high); //if value 1 led turns on
serial.println("on");
}
else if(data == '0') { // checks whether value of data equal 0
digitalwrite(13, low); //if value 0 led turns off
serial.println("off");
}
}
}
slave
code: [select]
#define button 8
int state = 20;
int buttonstate = 0;
void setup() {
pinmode(button, input);
pinmode(9, output);
serial.begin(9600); // default communication rate of bluetooth module
}
void loop() {
if(serial.available() > 0){ // checks whether data comming serial port
state = serial.read(); // reads data serial port
}
// reading button
buttonstate = digitalread(button);
if (buttonstate == high) {
serial.write('1'); // sends '1' master turn on led
digitalwrite(13, high);
}
else {
serial.write('0');
digitalwrite(13 , low);
}
}
anyone knew solution ?
Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Making two arduinos talk together via Bluesmurf
arduino
Comments
Post a Comment