The instructions link to 3 external libraries (MIDI, Bounce2, and mcp4278) and say to install these to your Arduino IDE. I installed the MIDI and Bounce2 libraries with no issue using Arduino 1.8.8, but when attempting to load the "mcp4728_library_v1.3_for_Arduino_1.0.zip" package, I get an error: "Specified folder/zip file does not contain a valid library."
I'm not actually even entirely clear on what the mcp4728 library does, as I couldn't find much documentation in the linked repository. So I'm wondering if this may have been built specifically for an older Arduino IDE or possibly different hardware? If it makes a difference... I am planning on using this USB AVR Programmer here: https://www.amazon.ca/USBtinyISP-Pro...ogrammer&psc=1
-Any ideas what the error means? Does this simply mean that this library is outdated and incompatible with my version of the Arduino software?
-Does anyone know what the mcp4728 library does exactly? Is there possibly a more up to date version of this library which should be used instead?
Unfortunately, the author of the mcp4278 did not structure the archive in a way that allows the downloaded .zip file to be directly installed using Sketch > Include Library > Add .ZIP Library. That can only be done when the .zip file has the library in the root. In the case of the mcp4278 library, the .zip file actually contains two different libraries, each in its own folder, thus the error message you got. However, the fix is easy enough:
Unzip the file mcp4728_library_v1.3_for_Arduino_1.0.zip
(In the Arduino IDE) Sketch > Include Library > Add .ZIP Library
Select the folder named mcp4728 that you extracted from the .zip file.
Click "Open".
The other library in the .zip file, SoftI2cMaster is required for the changeDeviceID example sketch that comes with the mcp4728 library. If you want to install the SoftI2cMaster library as well, you can do so by following the same procedure described above.
It's not obvious from the menu title, but Add .ZIP Library can be used to install libraries from folders as well as .zip files, which is what allows this solution to work.
WillMattWood:
Does this simply mean that this library is outdated and incompatible with my version of the Arduino software?
Arduino makes a good effort to maintain backwards compatibility. I installed the library in the newest version of the Arduino IDE and compiled one of the example sketches with no errors so I think the library is fine, even though it is quite old.
WillMattWood:
Is there possibly a more up to date version of this library which should be used instead?
That certainly is possible. The midithing project you're trying to use was written for the version of the library that it links to, so I think you'll be fine with that version. However, there may have been further development of the mcp4728 library in the years since that have made improvements or fixed bugs. Google Code shut down years ago and many of the projects were migrated to GitHub from there. My advice is to first get the midithing project working with the version of the library it links to. After that, you might do a little research to see if there is a newer version of the mcp4728 library available, and then try out midithing with that library. I don't recommend using a different version of the mcp4728 library from the start, since this just adds another complication to the project.
Hi again, so I was able to load the libraries succesfully and made an attempt to write the new firmware to the Befaco MIDI. I received an error message as follows:
ucr2 = deprecated, use 'uc3a0512'
I am still trying to research what this might mean... but I am wondering if it may be due to the "sketch" being written for a different bit of hardware? I did make a point of changing the "programmer" in Arduino to USBtinyISP but this did not help, I ran into the same error message.
The hardware suggested by Befaco was this one (I believe the name is USBASP).
The hardware I am using is this one (I believe the name is USBtinyISP).
When you encounter an error you'll see a button on the right side of the orange bar "Copy error messages" (or the icon that looks like two pieces of paper in the Arduino Web Editor). Click that button. Paste the error in a message here USING CODE TAGS (</> button on the forum toolbar). If the text exceeds the forum's 9000 character limit, save it to a text file and post it as an attachment. If you click the "Reply" button here, you will see an "Attachments and other settings" link.
WillMattWood:
I am wondering if it may be due to the "sketch" being written for a different bit of hardware? I did make a point of changing the "programmer" in Arduino to USBtinyISP but this did not help, I ran into the same error message.
The Tools > Programmer menu selection will never cause an error like this. The only error you can get from using the wrong programmer is an error in uploading, but this is a compilation error.
Okay so I traced back to the referenced points in the code (MIDIClass:340 and MIDILearn:414). Here is what I found...
MIDIClass:340 (line 340 is the 2nd line in this code snippet)
bool MIDICV::ChannelExists(byte channel, byte mininput, byte learnstep) {
int i;
for (int i = (learnstep - 2); i > -1; i--) {
if (Voice[i].midiChannel == channel && Voice[i].pitchDAC->minInput <= mininput) {
//new min notes in same channel have to be lower than old ones
return true;
}
}
return false;
}
I am tempted to believe that this code base should be solid, as it is being presented as a pick up and go solution for implementing a firmware update to the "MIDIthing" device. But is it possible there are just some errors in the code? I don't see what purpose "int i;" plays in this code and am thinking I should just deleted that or comment it out and try running again...
MIDILearn:414 (line 414 is the last curly bracket in the last line in this code snippet)
For this chunk I have no real working ideas about what's wrong with this section or why it would throw an error. Other chunks of code in this same section of the MIDILearn sketch start with "void" so my first thought was maybe starting off with "byte" was a bad move? But... I don't know. There don't appear to be any loose/single curly brackets, and I don't believe Arduino code cares about indent tabs/spaces formatting... so no idea.
/Users/zenstudio/Downloads/Arduino Libraries/midithing-master/firmware/MIDIClass.ino: In member function 'bool MIDICV::ChannelExists(byte, byte, byte)':
MIDIClass:340: warning: unused variable 'i'
int i;
^
MIDILearn: In function 'byte checkMenuMode(byte)':
MIDILearn:414: warning: control reaches end of non-void function
}
^
These are warnings, not errors. Warnings are the compiler telling you that something doesn't look right and you might want to have a look. It's a good idea to pay attention to warnings and to write your own code so that it doesn't produce any warnings. However, sometimes when you're working with someone else's code, they have not held themselves to such high standards and there will be warnings. It's often the case that these warnings don't represent any serious issues and it might make sense to just ignore them, rather than trying to improve someone else's code.
In this case, I would recommend that you at least not get distracted by the warnings until after you have resolved the real error:
WillMattWood:
avrdude: AVR Part "mk20dx256" not found.
This indicates something is wrong with your Teensyduino installation. Are you actually using a Teensy 3.2 or 3.1 board? You haven't mentioned anything about Teensy before this and I don't see anything about it on the midithing project page. I'm also not aware that you can even use the USBasp or USBtinyISP with a Teensy since those are AVR ISP programmers and the Teensy 3.2 and 3.1 does not use an AVR microcontroller.
Thank you again for a very detailed response pert, this is definitely helping me to learn. My Arduino installation was originally with an Arduino Teensy 3.2. I built a few small projects with this processor and have successfully run and tested a number of small programs with the Teensyduino so far with this Arduino IDE environment.
The MIDIthing seemed like an interesting new project and a chance to try talking to different kinds of external hardware. The Befaco page mentioned that it was possible to use Arduino software and an AVR Programmer to upload new code to the Befaco MIDIthing module. So I picked up an AVR Programmer, and this is what I am trying to use to upload the Arduino sketch to the Befaco MIDIthing (via a 6-pin AVR ISP connection and a USB to the computer running Arduino).
I do have a Teensyduino 3.2 as well, but I do not have a Teensyduino 3.2 connected to my computer when I try to "Upload Using Programmer" from the Arduino software. When I do try to execute the upload I have only the AVR Programmer (USBtinyISP) connected to my computer via USB.
Do I need to tell the Arduino software that I want to send my sketch to an AVR Programmer, not a Teensyduino 3.2? Is this specified in the Tools/Board selection? I did not see anything in there that seemed to match with my USBtinyISP model name, but I did find a listing for this specific piece of hardware in the Tools/Programmer" menu section...
You need to select the correct board from the Arduino IDE's Tools > Board menu. It's very annoying that Befaco doesn't bother to specify what you need to select in their otherwise pretty good instructions. I took a look at the user manual for the MIDI Thing and it seems to indicate that the correct selection is Tools > Board > Arduino/Genuino Uno. Give that a try.
Thank you again pert, I was able to get a successful upload confirmation using Arduino Genuino as the board in the Arduino software. I'm running into some bugs in the firmware but I'm in touch with the module designer to follow up on those, to see if I may have installed the firmware wrong or if I might be able to touch up/refine the code myself.
Just curious, where did you find the mention of the Genuino as the correct option to select? Would like to know so I can follow your steps for the next time I'm searching out which Board to use for a given project...
You're welcome. I'm glad if I was able to be of assistance.
WillMattWood:
Just curious, where did you find the mention of the Genuino as the correct option to select? Would like to know so I can follow your steps for the next time I'm searching out which Board to use for a given project...
I went to the web page for the Befaco Midi Thing: https://www.befaco.org/en/midi-thing/
and downloaded the "User Manual V2": https://www.befaco.org/docs/MIDI%20Thing/Midi_Thing%20_V2_User_Manual.pdf
On page 7, I found this text: "This module is based on the Arduino platform and features an Atmega328 microcontroller with Arduino UNO bootloader." I guessed that this means you can treat the Midi Thing as an Arduino Uno, and it looks like I guessed correctly. I'm not sure that specific process would apply to any other project, but it gives an example of how sometimes you need to go on a hunt for the smallest clues, do some "fuzzy thinking", make an educated guess, then give it a try. Hopefully you will find better documentation available to your future projects, but sadly this is not always the case. The need to select the Uno board is obvious to Befaco, but that missing sentence from the documentation can cause a lot of confusion to anyone else.
I have submitted a pull request to improve the instructions: