De-bug of beginner code- "GoBLE does not have a name"

Hi
Wondered if anyone had a few moments to help a beginner de bug a code I got from GitHub? Looking to connect to the GoBLE app with Arduino Uno but getting an error at line 19 and also line 23 comes up red.

Error message is saying "GoBLE does not have a name". I checked and I did include the reference at the start, any other ideas what I can try?
Thank you so very very much

Arduino Sketch Code:
#include <Servo.h>
#include "GoBLE.h"
#include "Metro.h"

Metro servoMove(50);

Servo myservoLF;
Servo myservoLR;
Servo myservoRF;
Servo myservoRR;

int centre = 82;
int minSpeed = 5;
int fullSpeed = 30;
int attached = 0;

int pinLED = 13;

GoBLE Goble(Serial);// init the bluetooth Serial port

int joystickX, joystickY;
int buttonState[7];

int speedL, speedR;

void attach () {
attached = 1;
myservoLF.attach(5);
myservoLR.attach(2);
myservoRF.attach(4);
myservoRR.attach(3);
digitalWrite(pinLED, HIGH);
}

void detach() {
attached = 0;
myservoLF.write(center);
myservoLR.write(center);
myservoRF.write(center);
myservoRR.write(center);
myservoLF.detach();
myservoLR.detach();
myservoRF.detach();
myservoRR.detach();
digitalWrite(pinLED, LOW);
}

void setup()}
Goble.begin();// init Goble and default baudrate is9600bps
Serial.begin(115200);//
pinMode(pinLED, OUTPUT);
}

void loop(){
if(Goble.available()){
joystickX=Goble.readJoystickY() - 128;
joystickY=Goble.readJoystickX() - 128;

buttonState[Switch_UP] =Goble.readSwitchUP();
buttonState[Switch_LEFT] =Goble.readSwitchLeft();
buttonState[Switch_RIGHT] =Goble.readSwitchRight();
buttonState[Switch_DOWN] =Goble.readSwitchDown();
buttonState[Switch_SELECT] =Goble.readSwitchSelect();
buttonState[Switch_START] =Goble.readSwitchStart();

speedL = (joystickY + joystickX) / (225 / fullSpeed);
speedR = (JoystickY - joystickX) / (225 / fullSpeed);
}
if (abs(speedL) < minSpeed) {
speedL = 0;
}
if (abs(speedR) < minSpeed) {
speedR = 0;
}
if (servoMove.check()) {
if (speedL == 0 && speedR == 0) {
if (attached) {
detach();
}
} else {
if(!attached) {
attach();
}
myservoLF.write(center - speedL);
myservoLR.write(center - speedL);
myservoRF.write(center + speedR);
myservoRR.write(center + speedR);
}
}
}

Please post the EXACT error message.
All of it.

Please remember to use code tags when posting code

PaperTiger2018:
Wondered if anyone had a few moments to help a beginner de bug a code I got from GitHub?

Please post a link to the GitHub page you got it from.

Thank you so much, just replying with the error message and Github link (BLE Microbot · GitHub) FYI the project I was trying to make is this one ( https://www.instructables.com/id/Arduino-based-4WD-Bluetooth-Microbot/)

Here is the error message I get ' GoBLE does not name a type'

and the text underneath:
./opt/arduino-builder/arduino-builder -compile -core-api-version 10611 -hardware opt/arduino-builder/hardware -hardware ./opt/cores -tools opt/arduino-builder/tools -tools ./opt/tools -built-in-libraries opt/libraries/latest -logger humantags -fqbn arduino:avr:uno -build-cache /tmp -build-path /tmp/312145094/build -verbose -prefs runtime.tools.avr-gcc.path=./opt/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2 -prefs runtime.tools.avrdude.path=./opt/tools/avrdude/6.3.0-arduino14 -prefs runtime.tools.arduinoOTA.path=./opt/tools/arduinoOTA/1.2.1 -libraries /tmp/312145094/custom -libraries /tmp/312145094/pinned /tmp/312145094/sketch_nov4b
Multiple libraries were found for "Servo.h"
Used: /home/ubuntu/opt/libraries/latest/servo_1_1_2
Not used: /home/ubuntu/opt/libraries/latest/rokitsmart_1_0_9
Not used: /home/ubuntu/opt/libraries/latest/printoo_library_1_0_2
Not used: /home/ubuntu/opt/libraries/latest/evive_2_0_1
Using library 0dde63c0-174b-4c94-a83c-6d6e5d57746e in folder: /tmp/312145094/custom/0dde63c0-174b-4c94-a83c-6d6e5d57746e (legacy)
Using library 377950d5-2165-47ce-be33-65089c0ce134 in folder: /tmp/312145094/custom/377950d5-2165-47ce-be33-65089c0ce134 (legacy)
/tmp/312145094/sketch_nov4b/sketch_nov4b.ino:19:1: error: 'GoBLE' does not name a type
GoBLE Goble(Serial);// init the bluetooth Serial port
^
/tmp/312145094/sketch_nov4b/sketch_nov4b.ino: In function 'void detach()':
/tmp/312145094/sketch_nov4b/sketch_nov4b.ino:38:19: error: 'center' was not declared in this scope
myservoLF.write(center);
^
/tmp/312145094/sketch_nov4b/sketch_nov4b.ino: At global scope:
/tmp/312145094/sketch_nov4b/sketch_nov4b.ino:49:14: error: expected initializer before '}' token
void setup()}
^
/tmp/312145094/sketch_nov4b/sketch_nov4b.ino:49:14: error: expected declaration before '}' token
exit status 1

void setup()} See the problem?

Can you also see why it is important to post what the compiler told you, verbatim?

Interesting. Did you type the whole program out by hand instead of copy/pasting it from the Gist?

Thank you, I corrected the void setup()} to now be void setup(){

Just re-ran it with the Uno. The error message still reads " GoBLE does not name a type" and seems to highlight the same piece of code

Yes I wrote out the code by hand as I tried to copy it and could paste it into notes etc, many many times but for some reason couldn't paste it directly into Arduino Sketch.

Sorry for the hassle, really appreciate any help.

PaperTiger2018:
Just re-ran it with the Uno. The error message still reads " GoBLE does not name a type" and seems to highlight the same piece of code

Post a link to where you got the GoBLE library from. Please use the chain links icon on the toolbar to make it clickable. Or if you installed it using Library Manger (Sketch > Include Library > Manage Libraries) then say so and state the full name of the library.

I saw the link on the Instructables page but that gave me a 404 error.

While you're at it, you might as well do the same with the Metro library.

PaperTiger2018:
Yes I wrote out the code by hand as I tried to copy it and could paste it into notes etc, many many times but for some reason couldn't paste it directly into Arduino Sketch.

If you like to type it out, that's fine. Some of the old timers swear by that as the only way to learn. Believe it or not, it used to be that the way you got computer programs was by copying them from of a magazine! So they learned that way and want everyone else to do the same. I disagree because I think it's a waste of time and often leads to these sorts of errors. I think the time you spend typing would be better spent studying the code, researching, and experimenting.

While you can just select the code from that Gist page, copy, and paste, that does introduce the possibility that you'll accidentally copy some of the non-code text from the page. For this reason, it's safer to first click the "Raw" button near the top right of the screen. That will give you a page of pure code text. At that point, you can even use the browser's File > Save Page as... feature to save the sketch directly to your computer if you don't want to do the copy/paste.

Thank you for your help. As you mentioned the instructables link to the libraries just gave a 404 error so I searched on Github and found another library for the both the h library and the metro library. The link is attached.
I then download and saved as zip folders and uploaded into my Sketch library so that they were there as a reference

I really appreciate any guidance. Super helpful on the copying code tip, trying to balance being a newbie and trying to learn by writing it all out to get a feel for the structure and just trying to see the bigger picture of how it works and copy the code.... its all a learning process

Thank you

It looks like the Instructables was written for a different version of the GoBLE library but it appears to be an easy fix. You only need to delete line 19 of the sketch:

GoBLE Goble(Serial);// init the bluetooth Serial port

The GoBLE library you found creates a global instance of the class named Goble. The library used by the Instructable appears to have been an improved version in that it allowed the user to pass the object to be used for communication but your GoBLE library has Serial hardcoded in so that will work as intended anyway.

After removing that line, the sketch should compile with no problems other than the ones you introduced when manually copying the code.

Thank you so much, really appreciate it. Think I'm getting there!
I would be grateful for any further advice but don't want to cause anyone too much trouble. Just interested to try and work through the errors and understand the sketch error messaging. The help on this forum so far has been invaluable.

I copied the code fresh from Github as per the instructions posted here, to remove all manual errors, then I removed row 19. I'm getting the following error: ' 'It' was not declared in this scope'.
I have red rows linking to lines

  • 3 where the code is: #include "Metro.h"
  • new line 19 where the code is :int joystickX, joystickY;
  • new line 46 which is a blank row
  • new line 68 where the code is : if (abs(speedL) < minSpeed) {

Reading the detailed error report looks like line 68 is the next error in the code, if I am understanding how to read the error report? Any hints would be gratefully accepted. Thanks so much

/tmp/063761283/Microbot/Microbot.ino:68:20: error: 'lt' was not declared in this scope
if (abs(speedL) < minSpeed) {
^
/tmp/063761283/Microbot/Microbot.ino:68:22: error: expected ')' before ';' token
if (abs(speedL) < minSpeed) {
^
/tmp/063761283/Microbot/Microbot.ino:68:32: error: expected ';' before ')' token
if (abs(speedL) < minSpeed) {
^
/tmp/063761283/Microbot/Microbot.ino:71:20: error: 'lt' was not declared in this scope
if (abs(speedR) < minSpeed) {
^
/tmp/063761283/Microbot/Microbot.ino:71:22: error: expected ')' before ';' token
if (abs(speedR) < minSpeed) {
^
/tmp/063761283/Microbot/Microbot.ino:71:32: error: expected ';' before ')' token
if (abs(speedR) < minSpeed) {
^
/tmp/063761283/Microbot/Microbot.ino:75:22: error: 'amp' was not declared in this scope
if (speedL == 0 && speedR == 0) {
^
/tmp/063761283/Microbot/Microbot.ino:75:25: error: expected ')' before ';' token
if (speedL == 0 && speedR == 0) {
^
/tmp/063761283/Microbot/Microbot.ino:75:27: error: 'amp' was not declared in this scope
if (speedL == 0 && speedR == 0) {
^
/tmp/063761283/Microbot/Microbot.ino:75:43: error: expected ';' before ')' token
if (speedL == 0 && speedR == 0) {
^
/tmp/063761283/Microbot/Microbot.ino:89:1: error: expected '}' at end of input
}
^
/tmp/063761283/Microbot/Microbot.ino:89:1: error: expected '}' at end of input
exit status 1

if (abs(speedL) &lt; minSpeed) {

if (abs(speedL) < minSpeed) {etc, etc,etc

That is very strange that you ended up with HTML character references instead of < and &. How exactly did you get the code from the Gist page? Which browser are you using?

Yeay!!!! Thank you, not sure how the symbols got changed when I imported but those switches corrected the code and I have a successful upload! Truly thank you so much... and I've learnt a valuable lessons to double check the code when I bring it in.

The blunto beetle now connects to the bluetooth on the GoBLE app and the RX now flashes everytime when I move the goBLE app... which is a positive... but the servo I've connected up won't move. Built it many times over and no control. Have tested the servo and works ok with the bluno without the app... so thinking there is a mistake in the code on the transmission from the RX signal to the servo... any ideas?

I'd start by running a simple test sketch for the servo like File > Examples > Servo > Sweep. That will tell you whether the servo itself is working. Make sure to adjust the line in setup():

  myservo.attach(9);  // attaches the servo on pin 9 to the servo object

according to whichever pin your servo is connected to.

pert:
That is very strange that you ended up with HTML character references instead of < and &. How exactly did you get the code from the Gist page? Which browser are you using?

I suspect the OP didn't use git, and then didn't select the raw or zip file option...

I've definitely seen where people use the browser's save page feature from the non-raw page and end up with an HTML version of the page. But that would have resulted in a ton more much more obvious errors. I don't remember ever seeing this particular issue before. I was thinking maybe its some browser-specific glitch when saving the raw page.

Thanks so much. I did a servo check before I attempted this project and again today after I couldn't get the first attempt to work.
Confirming the servo and bluno work correctly on a basic servo move code
The bluno now accepts the GoBLE sketch and connects to the app and receives the RX communication from the app
But my servo doesn't seem to respond... so think it must be an error in the communication of the sketch between the bluno and the servo
Thank you for any ideas

Add some Serial.print() statements and then use the Serial Monitor to check whether the communication is working as expected.