Connect computer to Redbear Duo via Bluetooth


#1

Hello!
I want to let a button (connected to the Redbear Duo) interact via bluetooth with a Java program I wrote. If you push on the button, a signal needs to be send to the computer.
The problem I have is to make the bluetooth work on the Redbear. I don’t know how to implement it in my code in Arduino IDE.
This is the very basic code I have:

#if defined(ARDUINO)
SYSTEM_MODE(SEMI_AUTOMATIC);
#endif

const int greenbutton = D8;
const int greenbuttonlight = D9;

// variables will change:
int PressGreen =0;

void setup() {
// put your setup code here, to run once:
pinMode(greenbutton,INPUT);
pinMode(greenbuttonlight,OUTPUT);

}

void loop() {
// put your main code here, to run repeatedly:
int PressGreen = digitalRead(greenbutton);
if(PressGreen){
digitalWrite(greenbuttonlight, HIGH);
Serial.println(“LED on”);
} else{
digitalWrite(greenbuttonlight,LOW);
Serial.println(“LED off”);
}

}

How can I send a signal over bluetooth to my computer when the button is pushed?


#2

This is a good question. I have not done it successfully, yet. I thing there are some things to consider. Please someone correct me if I am wrong.

The Duo uses BLE (Bluetooth low energy) while computers usually use BT (Normal Bluetooth). As Far as I know these are not compatible. An option I would like to try is the BLE dongle https://www.silabs.com/products/wireless/bluetooth/bluetooth-low-energy-modules/bled112-bluetooth-smart-dongle

I think maybe using a BLE Nano connected to the computer would work too. However, remember that Bluetooth has its own ways of connecting computers (not as easy as Master-Slave). So maybe you need to consider this too.