Bluno to Bluno

Does anyone have a basic Arduino sketch for a Bluno to Bluno connection? I was hoping to test the connection between two of my Bluno Nanos with a simple Arduino sketch that sends something like the blink command wirelessly, but I've been having issues with the one I've created.
2016-06-06 12:26:33 Hi sartbaug,
Just follow up about what I've done on my side, I used:
Description
I used the rotation sensor to change the input (0-255), and then transfer the input to another bluno wirelessly, different input will turn different LED on. And the old style green LED is to indicate the input of the actuator.
Connection
CODE
For Sender
For Receiver
Leff
Just follow up about what I've done on my side, I used:
- 2 x Bluno
- 2 x expansion shield for arduino
- 4 x LED
- 1 x Rotation sensor
- 1 x micro USB cable
- 1 x power adapter
Description
I used the rotation sensor to change the input (0-255), and then transfer the input to another bluno wirelessly, different input will turn different LED on. And the old style green LED is to indicate the input of the actuator.
Connection
CODE
For Sender
Code: Select all
//Bluno_Sender_AT+SETTING=DEFPERIPHERAL or AT+SETTING=DEFCENTRAL
int rotatorPin = A1;
int sensorValue = 0;
int ledPin = 11;
void setup() {
Serial.begin(115200);
}
void loop() {
sensorValue = analogRead(rotatorPin);
sensorValue = map(sensorValue, 0, 1023, 0, 255);
analogWrite(ledPin, sensorValue);
Serial.write(sensorValue);
delay(100); //can not be set as too fast, or the serial port would collapse
}
For Receiver
Code: Select all
//Bluno_Receiver_AT+SETTING=DEFCENTRAL or AT+SETTING=DEFPERIPHERAL
void setup() {
Serial.begin(115200);
}
void loop() {
while (Serial.available() > 0) {
int inCommand = Serial.read();
Serial.println(inCommand);
if (inCommand > 100 && inCommand < 150 ) {
digitalWrite(7, HIGH);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
}
else if (inCommand > 150 && inCommand < 200 ) {
digitalWrite(8, HIGH);
digitalWrite(7, LOW);
digitalWrite(9, LOW);
}
else if (inCommand > 200 && inCommand < 250 ) {
digitalWrite(9, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
}
else {
digitalWrite(9, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
}
}
}

2016-05-26 20:44:52 Thanks, I think I finally got it. I did "uint8_t" instead on both sides to create byte information for my three LEDs. Everything seems to be functioning as I would like it to, now. Now I just have to change the code to send char to CAN.
sartbaug

2016-05-26 14:53:26 Hi Sartbaug,
Thanks for your explaination, serial. print() is to print data to the serial port as human-reading ASC II text, and serial. write() is to write binary data to the serial port. And in your application you can use either one. What's more, Serial.println() would print two more charactors (CR & NL), but Arduino.cc did not say too much about Serial.read(), but to my experience, i prefer to use a Char variable to read the serial data, e.g.
besides, this is a similar test (with sample code) as yours viewtopic.php?f=5&t=1497&p=7596&hilit=apc220#p7596
Leff
Thanks for your explaination, serial. print() is to print data to the serial port as human-reading ASC II text, and serial. write() is to write binary data to the serial port. And in your application you can use either one. What's more, Serial.println() would print two more charactors (CR & NL), but Arduino.cc did not say too much about Serial.read(), but to my experience, i prefer to use a Char variable to read the serial data, e.g.
Code: Select all
char incomingData = Serial.read();
besides, this is a similar test (with sample code) as yours viewtopic.php?f=5&t=1497&p=7596&hilit=apc220#p7596

2016-05-26 02:30:39 I would say I'm just trying to send commands. When I push a button on one Bluno, I want the other one to read the button press and turn on an LED or send a message. I seem to have the devices up and running now. I have three buttons connected to the Master Bluno that activate three different LEDs on the Slave Bluno. My issue was with the Serial.write and Serial.read commands in Arduino IDE and my confusion about the Link LED.
sartbaug

2016-05-25 17:24:15 Hi sartbaug,
Sorry, may I confirm your intention to do wireless programming or just to send command with the two Bluno nanos?
Leff
Sorry, may I confirm your intention to do wireless programming or just to send command with the two Bluno nanos?

2016-05-24 21:31:34 As a follow up, I apparently have a bad Link LED on the Central Bluno. It's reading 3.3V across it currently, but the LED isn't on. So both of their Link LEDs should be on. When I press the button on Central Bluno to send the message, the Central Bluno's RX LED flashes and the Peripheral Bluno's TX LED flashes. This seems backwards to me, but I don't know what I'm doing wrong.
sartbaug

2016-05-24 20:45:29 Yes, I followed that guide. After I updated those and tried to run a program the one I set to peripheral had the Link LED on, but not the Bluno set to Central. I'm not sure if that is how it's supposed to appear or not, but when I try to send the blink command wirelessly with a button connected to the Central Bluno. The RX light blinks once on the Central device and the Peripheral device does nothing.
sartbaug

2016-05-24 16:26:17 Hi
If you establish a connection between two nanos, it is easy to send something like the blink command wirelessly. So do you make a connnection successfully between two nanos? To make a wireless programming via BLE, you can check the following link
http://www.dfrobot.com/wiki/index.php?title=Bluno_SKU:DFR0267#Wireless_Programming_via_BLE
Wendy.Hu
If you establish a connection between two nanos, it is easy to send something like the blink command wirelessly. So do you make a connnection successfully between two nanos? To make a wireless programming via BLE, you can check the following link
http://www.dfrobot.com/wiki/index.php?title=Bluno_SKU:DFR0267#Wireless_Programming_via_BLE
