Trying to install mcp4278 library to Arduino IDE v.1.8.8?

I am walking through the steps listed on this github page: GitHub - Befaco/midithing: Befaco Midi interface

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?

Thanks for any input or suggestions!
Cheers

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.

Thank you that was very helpful!

You're welcome. I'm glad if I was able to be of assistance. Enjoy!
Per

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.

Oh man that's embarrassing... okay so yes I found the complete error message. Copied below:

Arduino: 1.8.8 (Mac OS X), TD: 1.45, Board: "Teensy 3.2 / 3.1, Serial, 96 MHz (overclock), Faster, US English"

/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 
 }
 ^
Sketch uses 28496 bytes (10%) of program storage space. Maximum is 262144 bytes.
Global variables use 5508 bytes (8%) of dynamic memory, leaving 60028 bytes for local variables. Maximum is 65536 bytes.
avrdude: AVR Part "mk20dx256" not found.

Valid parts are:
  uc3a0512 = AT32UC3A0512
  c128     = AT90CAN128
  c32      = AT90CAN32
  c64      = AT90CAN64
  pwm2     = AT90PWM2
  pwm216   = AT90PWM216
  pwm2b    = AT90PWM2B
  pwm3     = AT90PWM3
  pwm316   = AT90PWM316
  pwm3b    = AT90PWM3B
  1200     = AT90S1200
  2313     = AT90S2313
  2333     = AT90S2333
  2343     = AT90S2343
  4414     = AT90S4414
  4433     = AT90S4433
  4434     = AT90S4434
  8515     = AT90S8515
  8535     = AT90S8535
  usb1286  = AT90USB1286
  usb1287  = AT90USB1287
  usb162   = AT90USB162
  usb646   = AT90USB646
  usb647   = AT90USB647
  usb82    = AT90USB82
  m103     = ATmega103
  m128     = ATmega128
  m1280    = ATmega1280
  m1281    = ATmega1281
  m1284    = ATmega1284
  m1284p   = ATmega1284P
  m1284rfr2 = ATmega1284RFR2
  m128rfa1 = ATmega128RFA1
  m128rfr2 = ATmega128RFR2
  m16      = ATmega16
  m161     = ATmega161
  m162     = ATmega162
  m163     = ATmega163
  m164p    = ATmega164P
  m168     = ATmega168
  m168p    = ATmega168P
  m168pb   = ATmega168PB
  m169     = ATmega169
  m16u2    = ATmega16U2
  m2560    = ATmega2560
  m2561    = ATmega2561
  m2564rfr2 = ATmega2564RFR2
  m256rfr2 = ATmega256RFR2
  m32      = ATmega32
  m3208    = ATmega3208
  m3209    = ATmega3209
  m324p    = ATmega324P
  m324pa   = ATmega324PA
  m325     = ATmega325
  m3250    = ATmega3250
  m328     = ATmega328
  m328p    = ATmega328P
  m328pb   = ATmega328PB
  m329     = ATmega329
  m3290    = ATmega3290
  m3290p   = ATmega3290P
  m329p    = ATmega329P
  m32m1    = ATmega32M1
  m32u2    = ATmega32U2
  m32u4    = ATmega32U4
  m406     = ATMEGA406
  m48      = ATmega48
  m4808    = ATmega4808
  m4809    = ATmega4809
  m48p     = ATmega48P
  m48pb    = ATmega48PB
  m64      = ATmega64
  m640     = ATmega640
  m644     = ATmega644
  m644p    = ATmega644P
  m644rfr2 = ATmega644RFR2
  m645     = ATmega645
  m6450    = ATmega6450
  m649     = ATmega649
  m6490    = ATmega6490
  m64m1    = ATmega64M1
  m64rfr2  = ATmega64RFR2
  m8       = ATmega8
  m8515    = ATmega8515
  m8535    = ATmega8535
  m88      = ATmega88
  m88p     = ATmega88P
  m88pb    = ATmega88PB
  m8u2     = ATmega8U2
  t10      = ATtiny10
  t11      = ATtiny11
  t12      = ATtiny12
  t13      = ATtiny13
  t15      = ATtiny15
  t1604    = ATtiny1604
  t1606    = ATtiny1606
  t1607    = ATtiny1607
  t1614    = ATtiny1614
  t1616    = ATtiny1616
  t1617    = ATtiny1617
  t1634    = ATtiny1634
  t20      = ATtiny20
  t202     = ATtiny202
  t204     = ATtiny204
  t212     = ATtiny212
  t214     = ATtiny214
  t2313    = ATtiny2313
  t24      = ATtiny24
  t25      = ATtiny25
  t26      = ATtiny26
  t261     = ATtiny261
  t28      = ATtiny28
  t3214    = ATtiny3214
  t3216    = ATtiny3216
  t3217    = ATtiny3217
  t4       = ATtiny4
  t40      = ATtiny40
  t402     = ATtiny402
  t404     = ATtiny404
  t406     = ATtiny406
  t412     = ATtiny412
  t414     = ATtiny414
  t416     = ATtiny416
  t417     = ATtiny417
  t4313    = ATtiny4313
  t43u     = ATtiny43u
  t44      = ATtiny44
  t441     = ATtiny441
  t45      = ATtiny45
  t461     = ATtiny461
  t5       = ATtiny5
  t804     = ATtiny804
  t806     = ATtiny806
  t807     = ATtiny807
  t814     = ATtiny814
  t816     = ATtiny816
  t817     = ATtiny817
  t84      = ATtiny84
  t841     = ATtiny841
  t85      = ATtiny85
  t861     = ATtiny861
  t88      = ATtiny88
  t9       = ATtiny9
  x128a1   = ATxmega128A1
  x128a1d  = ATxmega128A1revD
  x128a1u  = ATxmega128A1U
  x128a3   = ATxmega128A3
  x128a3u  = ATxmega128A3U
  x128a4   = ATxmega128A4
  x128a4u  = ATxmega128A4U
  x128b1   = ATxmega128B1
  x128b3   = ATxmega128B3
  x128c3   = ATxmega128C3
  x128d3   = ATxmega128D3
  x128d4   = ATxmega128D4
  x16a4    = ATxmega16A4
  x16a4u   = ATxmega16A4U
  x16c4    = ATxmega16C4
  x16d4    = ATxmega16D4
  x16e5    = ATxmega16E5
  x192a1   = ATxmega192A1
  x192a3   = ATxmega192A3
  x192a3u  = ATxmega192A3U
  x192c3   = ATxmega192C3
  x192d3   = ATxmega192D3
  x256a1   = ATxmega256A1
  x256a3   = ATxmega256A3
  x256a3b  = ATxmega256A3B
  x256a3bu = ATxmega256A3BU
  x256a3u  = ATxmega256A3U
  x256c3   = ATxmega256C3
  x256d3   = ATxmega256D3
  x32a4    = ATxmega32A4
  x32a4u   = ATxmega32A4U
  x32c4    = ATxmega32C4
  x32d4    = ATxmega32D4
  x32e5    = ATxmega32E5
  x384c3   = ATxmega384C3
  x384d3   = ATxmega384D3
  x64a1    = ATxmega64A1
  x64a1u   = ATxmega64A1U
  x64a3    = ATxmega64A3
  x64a3u   = ATxmega64A3U
  x64a4    = ATxmega64A4
  x64a4u   = ATxmega64A4U
  x64b1    = ATxmega64B1
  x64b3    = ATxmega64B3
  x64c3    = ATxmega64C3
  x64d3    = ATxmega64D3
  x64d4    = ATxmega64D4
  x8e5     = ATxmega8E5
  ucr2     = deprecated, use 'uc3a0512'

An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

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)

byte checkMenuMode( byte channel )
{
 if (calProcEnabled) {
   return CALMODE;
 } else if (channel == 1) {
   return CHANGEMODE;
 } else if (channel == 2) {
   return CHANGEOPTIONS;
 }
}

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.

WillMattWood:

/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.

Valid parts are:
uc3a0512 = AT32UC3A0512
c128 = AT90CAN128
c32 = AT90CAN32
c64 = AT90CAN64
pwm2 = AT90PWM2
pwm216 = AT90PWM216
pwm2b = AT90PWM2B
pwm3 = AT90PWM3
pwm316 = AT90PWM316
pwm3b = AT90PWM3B
1200 = AT90S1200
2313 = AT90S2313
2333 = AT90S2333
2343 = AT90S2343
4414 = AT90S4414
4433 = AT90S4433
4434 = AT90S4434
8515 = AT90S8515
8535 = AT90S8535
usb1286 = AT90USB1286
usb1287 = AT90USB1287
usb162 = AT90USB162
usb646 = AT90USB646
usb647 = AT90USB647
usb82 = AT90USB82
m103 = ATmega103
m128 = ATmega128
m1280 = ATmega1280
m1281 = ATmega1281
m1284 = ATmega1284
m1284p = ATmega1284P
m1284rfr2 = ATmega1284RFR2
m128rfa1 = ATmega128RFA1
m128rfr2 = ATmega128RFR2
m16 = ATmega16
m161 = ATmega161
m162 = ATmega162
m163 = ATmega163
m164p = ATmega164P
m168 = ATmega168
m168p = ATmega168P
m168pb = ATmega168PB
m169 = ATmega169
m16u2 = ATmega16U2
m2560 = ATmega2560
m2561 = ATmega2561
m2564rfr2 = ATmega2564RFR2
m256rfr2 = ATmega256RFR2
m32 = ATmega32
m3208 = ATmega3208
m3209 = ATmega3209
m324p = ATmega324P
m324pa = ATmega324PA
m325 = ATmega325
m3250 = ATmega3250
m328 = ATmega328
m328p = ATmega328P
m328pb = ATmega328PB
m329 = ATmega329
m3290 = ATmega3290
m3290p = ATmega3290P
m329p = ATmega329P
m32m1 = ATmega32M1
m32u2 = ATmega32U2
m32u4 = ATmega32U4
m406 = ATMEGA406
m48 = ATmega48
m4808 = ATmega4808
m4809 = ATmega4809
m48p = ATmega48P
m48pb = ATmega48PB
m64 = ATmega64
m640 = ATmega640
m644 = ATmega644
m644p = ATmega644P
m644rfr2 = ATmega644RFR2
m645 = ATmega645
m6450 = ATmega6450
m649 = ATmega649
m6490 = ATmega6490
m64m1 = ATmega64M1
m64rfr2 = ATmega64RFR2
m8 = ATmega8
m8515 = ATmega8515
m8535 = ATmega8535
m88 = ATmega88
m88p = ATmega88P
m88pb = ATmega88PB
m8u2 = ATmega8U2
t10 = ATtiny10
t11 = ATtiny11
t12 = ATtiny12
t13 = ATtiny13
t15 = ATtiny15
t1604 = ATtiny1604
t1606 = ATtiny1606
t1607 = ATtiny1607
t1614 = ATtiny1614
t1616 = ATtiny1616
t1617 = ATtiny1617
t1634 = ATtiny1634
t20 = ATtiny20
t202 = ATtiny202
t204 = ATtiny204
t212 = ATtiny212
t214 = ATtiny214
t2313 = ATtiny2313
t24 = ATtiny24
t25 = ATtiny25
t26 = ATtiny26
t261 = ATtiny261
t28 = ATtiny28
t3214 = ATtiny3214
t3216 = ATtiny3216
t3217 = ATtiny3217
t4 = ATtiny4
t40 = ATtiny40
t402 = ATtiny402
t404 = ATtiny404
t406 = ATtiny406
t412 = ATtiny412
t414 = ATtiny414
t416 = ATtiny416
t417 = ATtiny417
t4313 = ATtiny4313
t43u = ATtiny43u
t44 = ATtiny44
t441 = ATtiny441
t45 = ATtiny45
t461 = ATtiny461
t5 = ATtiny5
t804 = ATtiny804
t806 = ATtiny806
t807 = ATtiny807
t814 = ATtiny814
t816 = ATtiny816
t817 = ATtiny817
t84 = ATtiny84
t841 = ATtiny841
t85 = ATtiny85
t861 = ATtiny861
t88 = ATtiny88
t9 = ATtiny9
x128a1 = ATxmega128A1
x128a1d = ATxmega128A1revD
x128a1u = ATxmega128A1U
x128a3 = ATxmega128A3
x128a3u = ATxmega128A3U
x128a4 = ATxmega128A4
x128a4u = ATxmega128A4U
x128b1 = ATxmega128B1
x128b3 = ATxmega128B3
x128c3 = ATxmega128C3
x128d3 = ATxmega128D3
x128d4 = ATxmega128D4
x16a4 = ATxmega16A4
x16a4u = ATxmega16A4U
x16c4 = ATxmega16C4
x16d4 = ATxmega16D4
x16e5 = ATxmega16E5
x192a1 = ATxmega192A1
x192a3 = ATxmega192A3
x192a3u = ATxmega192A3U
x192c3 = ATxmega192C3
x192d3 = ATxmega192D3
x256a1 = ATxmega256A1
x256a3 = ATxmega256A3
x256a3b = ATxmega256A3B
x256a3bu = ATxmega256A3BU
x256a3u = ATxmega256A3U
x256c3 = ATxmega256C3
x256d3 = ATxmega256D3
x32a4 = ATxmega32A4
x32a4u = ATxmega32A4U
x32c4 = ATxmega32C4
x32d4 = ATxmega32D4
x32e5 = ATxmega32E5
x384c3 = ATxmega384C3
x384d3 = ATxmega384D3
x64a1 = ATxmega64A1
x64a1u = ATxmega64A1U
x64a3 = ATxmega64A3
x64a3u = ATxmega64A3U
x64a4 = ATxmega64A4
x64a4u = ATxmega64A4U
x64b1 = ATxmega64B1
x64b3 = ATxmega64B3
x64c3 = ATxmega64C3
x64d3 = ATxmega64D3
x64d4 = ATxmega64D4
x8e5 = ATxmega8E5
ucr2 = deprecated, use 'uc3a0512'

An error occurred while uploading the sketch

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...

Thanks again.

WillMattWood:
Thank you again pert

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: