0

Thank you for considering my question.

I have been learning Arduino so I can teach coding basics to my son. I came across a fun project to interface bluetooth with an old singing Billy Bass so he can have the fish read books to him from his Yoto player.

Original Build: https://maker.pro/arduino/projects/how-to-animate-billy-bass-with-bluetooth-audio-source

Original Code: https://github.com/TensorFlux/BTBillyBass

The code is intended for an Arduino Nano and calls a library named MX1508, which drives an H-bridge so the mouth and tail motors can run in both directions. My issue is with that library.

Compilation error: 'class MX1508' has no member named 'setSpeed'

This same error occurs both in the code written for the project, as well as in the library's provided test file. I've tried to test common library errors by tracking the library location and reinstalling Arduino IDE, and the problem remains. Searching for others with this problem, I found a gleeful redditor. Ironically, the post that solved their problem has since been deleted in the 2023 API strike. Other posters' questions on other forums are still lingering unanswered.

Below I will post the simpler code of the library test file rather than the project, which shares the same error. Thank you.

Edit: I have tried three separate library install methods. The first was the library manager, searching for and installing the entry labeled "MX1508". This was the first time seeing the listed error. The creator name (Cheng Saeturn) differed from the name listed in the build description, so I also tried manually placing the MX1508 folder from github into the folder (Arduino>BTBillyBass>libraries>MX1508). This didn't work so I again noticed this same author, and that the methods and functions are different. The last attempt probably should have been my first, which was simply using the github link listed in the build description. The download is a master folder with both the .ino file and the MX1508 library included. (Arduino>BTBillyBass-master>BTBillyBass & >libraries>MX1508). I deleted "-master" from the folder to match the .ino and opened the sketch. I set the board to Nano and compiled; same error. The library code listed in this question is from the third attempt with the correct library author.

Edit 2: I retraced my steps to add my library install method for the test file and discovered my mistake. I had neglected to delete the original incorrect library with the same name from the Arduino folder. I deleted it, replaced it with the correct library (which to this point had been in the sketch folder but not the Arduino folder) and now both the original sketch and the test sketch compile successfully.

MX1508Test.ino

#include <MX1508.h>
MX1508 Motor(3, 5); //sets up a motor on PWM pins 3 and 5
void setup() {
 Motor.setSpeed(255); //sets the PWM speed (between 0 and 255)
}
void loop() {
 Motor.forward(); //runs the motor forward
 delay(1000);
 Motor.halt(); //stops the motor
 delay(1000);
 Motor.backward(); // runs the motor backward
 delay(1000);
 Motor.halt();
 delay(1000);
}

MX1508.cpp

/*
 MX1508 - A library for controlling cheap H-bridges using the MX1508 driver chip
 Created 2019 by Jordan Bunker <[email protected]>
 Released into the public domain
*/
#include <MX1508.h>
MX1508::MX1508(int pin1, int pin2) {
 pinMode(pin1, OUTPUT);
 _pin1 = pin1;
 pinMode(pin2, OUTPUT);
 _pin2 = pin2;
}
void MX1508::forward() {
 analogWrite(_pin1, _motorSpeed);
 digitalWrite(_pin2, LOW);
}
void MX1508::backward() {
 digitalWrite(_pin1, LOW);
 analogWrite(_pin2, _motorSpeed);
}
void MX1508::setSpeed(int motorSpeed) {
 _motorSpeed = motorSpeed;
}
void MX1508::halt() {
 digitalWrite(_pin1, HIGH);
 digitalWrite(_pin2, HIGH);
}

MX1508.h

/*
 MX1508 - A library for controlling cheap H-bridges using the MX1508 driver chip
 Created 2019 by Jordan Bunker <[email protected]>
 Released into the public domain
*/
#ifndef MX1508_H
#define MX1508_H
#if (ARDUINO >=100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
class MX1508 {
 public:
 // Constructor
 MX1508(int pin1, int pin2);
 // Methods
 void forward();
 void backward();
 void setSpeed(int motorSpeed);
 void halt();
 private:
 int _pin1;
 int _pin2;
 int _motorSpeed;
};
#endif
asked May 27 at 23:33
5
  • I can't reproduce what you described based on the one downloaded from the GitHub repository. Commented May 28 at 4:57
  • please update your post with a description of your library install procedure ... edit the post, do not write a comment Commented May 28 at 7:48
  • Retracing my steps was a good suggestion. I edited the post to include my mistake and resolution for compilation. I will upload the sketch this evening and write the answer at that point, assuming all goes well with the upload. Commented May 28 at 17:55
  • The GitHub repository is not packed as an Arduino Library. So you can't just using Library Manager to install it. But improper install of library does not give the error of class MX1508 has no member named 'setSpeed. It simply tell you "MX1508 is not found" or something like that.. Commented May 29 at 0:56
  • To properly install the library, move the MAX1508 folder(not the libraries folder) into the directory where you keep all the libraries on your PC. Commented May 29 at 1:01

1 Answer 1

1

The problem is solved, the sketch compiles & uploads, and the fish is powered, links to bluetooth, responds to amp and potentiometer, and flaps and talks as intended.

The issue was due to there being two separate libraries named "MX1508". Because I first used the library manager which holds the wrong version of MX1508, the sketch was able to read a properly named library in the proper location that contained improper functions. This lead to the "has no member named" error rather than a "is not found" error.

Deleting the incorrect library, then replacing it in the library directory with the version authored by Jordan Bunker was the needed solution.

Additional notes: Input volume from phone/etc. must be set to max. Potentiometer pinout in build is incorrect. Left=GND; Center=Output(A0 Arduino); Right=Input(BT module).

answered May 29 at 20:28

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.