1

So I have a working project with Arduino Uno. I now want to migrate it to the Beetle BlunoThe bluno beetle. I tried running the code on the Beetle and it does work. I cannot seem to get the Bluetooth to work though. The code is below:

#include <Bounce2.h>
#include <SoftwareSerial.h>
//#include <Wire.h>
//SoftwareSerial bluetooth_port(10, 11);
// Connect each button with one connection
// to GND and the other to a digital pin.
const byte buttonPinBLE1 = 2;
const byte buttonPinBLE2 = 3;
class Button{
 private:
 byte m_buttonPin;
 byte m_counter = 0;
 unsigned long m_buttonPressTimeout;
 unsigned long m_previousMillis;
 public:
 Button(byte buttonPin):
 m_buttonPin(buttonPin),
 m_counter(0),
 m_buttonPressTimeout(1500), // Button press timeout in ms.
 m_previousMillis(0){}
 void Update(){
 if(m_counter > 0 && millis() - m_previousMillis >= m_buttonPressTimeout)
 {
 //Serial.print("Count from Update() just before it's reset to 0 = ");
 Serial.println(GetCounter());
 m_counter = 0;
 }
 }
 void IncrementCounter(){
 m_counter++;
 if(m_counter > 4){m_counter = 4;}
 if(m_counter == 1)
 {
 m_previousMillis = millis();
 }
 }
 friend void IncrementCounter(Button&);
 void IncrementCounter(Button&){
 IncrementCounter();
 }
 byte GetCounter(){
 return m_counter;
 }
};
Bounce buttonOneDebouncer = Bounce();
Bounce buttonTwoDebouncer = Bounce();
Button ButtonOne(buttonPinBLE1);
Button ButtonTwo(buttonPinBLE2);
void setup(){
 //Serial.begin(9600);
 Serial.begin(115200);
 pinMode(buttonPinBLE1, INPUT_PULLUP);
 pinMode(buttonPinBLE2, INPUT_PULLUP);
 buttonOneDebouncer.attach(buttonPinBLE1);
 buttonTwoDebouncer.attach(buttonPinBLE2);
 buttonOneDebouncer.interval(25);
 buttonTwoDebouncer.interval(25);
}
void loop(){
 // Call the Update function as fast as possible.
 ButtonOne.Update();
 ButtonTwo.Update();
 // Button one pressed.
 if(buttonOneDebouncer.update()){
 if(buttonOneDebouncer.fell()){
 if(digitalRead(buttonPinBLE2) == 0){
 ButtonOne.IncrementCounter();
 }
 }
 }
 // Button two pressed.
 if(buttonTwoDebouncer.update()){
 if(buttonTwoDebouncer.fell()){
 if(digitalRead(buttonPinBLE1) == 0){
 ButtonOne.IncrementCounter(ButtonTwo);
 }
 }
 }
 if(digitalRead(buttonPinBLE1) == 0 && (digitalRead(buttonPinBLE2) == 0))
 {
 Serial.println("9");
 }
}

Does anyone know how I can get the device to communicate with my computer via Bluetooth? I have no experience with the Beetle and I cannot seem to find much help online.

asked Jan 15, 2020 at 22:26
4
  • Comments are not for extended discussion; this conversation has been moved to chat. Commented Jan 17, 2020 at 14:45
  • @VE7JRO Hello. You helped me with the single tap, double tap question (arduino.stackexchange.com/questions/69897/…). Thank you so much for that once more. However, it isn't accurate and sometimes if i press the buttons once, it outputs a 2, sometimes it outputs a 4 when i press it twice. Do you know how I can fix this issue? Commented Jan 19, 2020 at 1:06
  • The original code I provided in the linked Q+A worked perfectly on a Arduino Uno. The sketch you are using in this question is different. I do not have a Beetle Bluno to test with, so I'm sorry, but I can't help you. If I can't test the sketch on the "same" hardware, then I'm just guessing, not answering. Commented Jan 19, 2020 at 1:28
  • @VE7JRO the code I am using is on an Arduino Uno...it isn't working accurately for some reason on my side. I haven't started using the Beetle as yet so still testing on the Arduino Uno Commented Jan 19, 2020 at 3:04

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.