By sartbaug
#9057
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.
By sartbaug
#9077
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.
By sartbaug
#9079
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.
By Leff
#9085
Hi sartbaug,

Sorry, may I confirm your intention to do wireless programming or just to send command with the two Bluno nanos?
By sartbaug
#9093
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.
By Leff
#9100
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.

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
By sartbaug
#9106
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.
By Leff
#9214
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.

(3.36 MiB) Downloaded 9246 times


Connection

(78.32 KiB) Downloaded 1020 times



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);
    }
  }
}