How do I include classes

I want to use Rolf Kurst sketch as a starting point for a balancing robot. His version has all the elements I want. Here is location: two wheeled self balancing robot with stepper motor. - Hackster.io
I have downloaded the main code "srobotduep6500_newpwm_55" but it has a number of classes to be included. How do I do this from the webpage shown above? I had a previous version (the one above is latest) that had all the files in one folder, but I got a ton of errors trying to compile it: files not found, classes not found, errors within the classes, etc. I looked at some of the classes and noticed all the .h and .cpp files were capitalized, but the file names were not, so I capitalized all of them but errors persist.
And another thing, before I even started the classes had this type of naming convention: eg config_cpp.c and config_h.c. I renamed them config.cpp and config.h. Was this correct way to do this? I've asked for help from the author and the website, but no responses. If someone could try and successfully compile the code (for a Due), and let me know how this works, would be a godsend

It looks like you used incompatible browser for download the project.

I don't see any files there with names like config_h.c...
The standard naming system is used - file .h and .cpp - for example, Vehicle.h and Vehicle.cpp.
All names are consistent to includes in the code.
The main file is SBRobotDueDP6500_NewPWM_55.ino, and not the "srobotduep6500_newpwm_55" as you named it.

As far as I can see, all these files should be in the same folder.
Try to download project again.

I was using Chrome, switched to Edge, downloaded 2 or 3 times, with same result. The main file is as you said, (typo mistake) but does NOT end with "xx55.ino". It ends with xx55_ino.c. I renamed it to xx55.ino, put it in a folder, but none of the other files (classes) loaded. See uploaded screen shots. The (1) appears because I already had a previous download.
ScreenShot_20220818114307
ScreenShot_20220818114614

No other file will download itself, you have to download each separately by switching tabs on the source code widget.

I downloaded the whole project
You're right, file extensions get corrupted when downloaded. But I corrected them in place.

SBRobotDueDP6500_NewPWM_55.zip (35.4 KB)

Have you bought the required "Megunolink" software yet?

No...thought it was free, but I commented it out anyway to concentrate on parts that I really needed.

Yes I had been doing that with the latest version the one with the "megunolink" link in the sketch. However, a very early version of this program DID include all the classes. Since I had those files I tried to use them, but ran into other problems. (The more I tried to fix, the deeper in trouble I got).

Thanks buddy. Downloaded it, got all the files with proper extensions. So now I assume I just add these as "tabs" with the main program? Is there a "bulk add" to do this?
A favor: can you try to compile the sketch for a DUE? If you can do...then so can I!!

You can refer to how to create Class and Object on Arduino IDE

You don't need add the "tabs" manually - just uncompress the zip and go to main ino file SBRobotDueDP6500_NewPWM_55.ino with arduino ide. The other files will open in tabs automatically

Well I really thought I was on a roll here, because after decompressing and opening the main file in Arduino IDE, all the classes were there as you said. I commented out the Megunalink line, then compiled and getting the same errors I did before. The very first one has to do with the config.h class:
In member function 'void Vehicle::Run(MpuYawPitchRoll, int&, int&, JStickData)':
Vehicle.cpp:134:11: error: 'class DuePWMmod' has no member named 'setFreq2'
ptrpwm->setFreq2( freqA, freqB );
And then a bunch more errors after that. Can someone try to compile this for a DUE to see if you get the same errors? I don't know enough about all this stuff to delve into it, whereas it could be a simple fix for an expert. I'm close to abandoning this entire sketch because I found another that compiled right off the bat with none of these issues.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.