Importing a. zip library for digital potentiometer MCP4xxx

I was thinking it might be helpful to import a Arduino software library for the digital pots MCP4xxx. I found a couple and liked this one. GitHub - jmalloc/arduino-mcp4xxx: Control a Microchip MCP4XXX digital potentiometer with an Arduino.
I have never imported a .zip library. I went to Sketch>Include Library> Add.ZIP Library, and selected "Add.ZIP Library". I was prompted to select the library I would like to add. I navigated to the .zip file's location and opened it. I returned to Sketch >Include Library menu. I thought I was supposed to see the library at the bottom of the drop-down menu. I did not see the library at the bottom of the drop-down menu.
What am I doing wrong? Also, will this library make it easier for me to write code for the MCP4231. Thanks!

When you add a library, whether from a .zip file or by copying the files manually, the library should be visible in the list when you use Include Library

However, do not expect the newly installed library to be at the end of the list. It may be elsewhere in the list or in a different section of the list

Having said that, if the contents of the zip have not been correctly defined by the library author then the library may fail to install and/or be visible

Have you tried the manual method of installation described at the link that you posted ?

Thanks for the reply. When I try to do it the automatic way, the Arduino says it is not valid. If I try the manual way, it says it can not find it. The zip file is arduino-mcp4xx-1.0.0

What exactly did you do when you installed the library manually ?

It is important that the name of the library folder is correct, that it is in the libraries folder of you sketchbook folder and that the .h and .cpp files are in that folder. The library should then be available for selection using Include Library from the IDE menu

I have just installed the library manually and it is available for selection

image

Here is the problem I am having. I have downloaded arduino-mcp4xxx-1.0.0 into Windows Downloads This PC. When I click on arduino-mcp4xxx-1.0.0 it opens up then lists two files mcp4xxx .cpp file and mcp4xxx .H file. I can not figure out how to move these two files to Sketch > Library> add.ZIP library. I realize I have to add these two files to the ZIP library in the IDE.
Instructions say to exit the Arduino IDE. Then copy mcp4xxx. h and mcp4xxx. cpp files to a folder named mcp4xxx in your Arduinio libraries folder.
I don't have a Arduino libraries folder unless I open the IDE---AND THEY JUST TOLD ME TO EXIT THE IDE????????????? Furthermore I don't know how to make a Arduino libraries folder, and if I did, I would not know how to get it back to the IDE. The instructions then say to restart the Arduino IDE and the library should now be available for use.
The problem I am having is simple: I have the two items downloaded into Windows, Downloads This PC. I can not get them into the IDE library Add.ZIP Library. In other words I can't move the files---I simply don't know how. The instructions for importing a zip library automatically, or manually, is not working for me. The reason is because I can not move the two files out of Windows Downloads This PC, and into the add zip library. I have tried many things and none of them work.

Let's take this step by step

  • In the IDE select File/Preferences and a window will open. At the top of the window you will see something like this
  • make a note of the sketchbook location
  • close the Preferences window
  • open Windows File Explorer and navigate to the sketchbook folder
  • in that folder there is a folder name libraries. Open that folder
  • in that libraries folder create a new folder named mcp4xxx and open it
  • locate the .zip file that you downloaded and open it
  • drag the .h and .cpp files into the folder that you just created
  • close the folders
  • back in the IDE you should now be able to see the mcp4xxx library in Sketch/Include Library

I will follow step by step. I have not had time today to do it. I will do it soon. Hopefully I don't get hung up. Thanks

I made time to do it. I got down to the line: "Open Windows File Explorer and navigate to the sketchbook folder". I did that and all my sketches I had saved on the IDE were there. But that was all that was there. There was no folder named libraries. All that was there was copies of the sketches, same copies of the sketches saved in the IDE. So if the folder named libraries was not there---how do I get to it? It is no where to be found in the File Explorer.

That is quite odd

Have you ever installed a library by using "Add .ZIP library" and, if so, which one ?

No, I have never installed a "Add.ZIP library".
I went to the IDE selected File/Preferences to look for Sketchbook location. It listed C:\Users\khil\Documents\Arduino I closed the IDE and did a Windows search on my computer and a Windows screen came up saying it could not find that on my computer.

Don't worry. I was just looking for a way to shortcut finding the library folder

Are you absolutely sure that your sketchbook folder, found by looking in File/Preferences in the IDE does not have a folder in it names libraries ?

Just out of interest please post the full path to your sketchbook folder

Actually, belay that and open Tools/Manage Libraries in the IDE and put MCP4 in the search bar and you will find several libraries for the MCP4 family which should install with no problem. Install one of them then report what happens.

Can you see the examples for the library you just installed in File/Examples ?

I went to the Libraries and typed in Digital Potentiometer and I found this:
MCP4xxx Arduino Driver. I installed that and it was then listed in my list if libraries. Have not went to File/Examples. I will try to go there, because I need to know how this can help me code with the MCP4xxx. I am guessing this library is as good as the other one, is that correct?

Sorry for getting ahead. Let me go back and answer the questions you asked.
"Are you absolutely sure that your sketchbook folder, found by looking in File/Preferences in the IDE does not have a folder in it names libraries ?" Yes, I am sure there is no folder there named libraries.
"Just out of interest please post the full path to your sketchbook folder". Full path was This PC Documents Arduino.
"Can you see the examples for the library you just installed in File/Examples ?" No the file I just installed MCP4XXx Arduino Driver shows no examples in File/Examples. I went back to Tools/Manage Libraries and looked up what I installed MCP4xxx Arduino Driver. I clicked on the space that said more information---a page come up saying 404 Not Found. So I guess there is no information available. No examples. I would really like to see some examples of this library? How do I find examples of this library?

First to determine if the library is installed.

When the OP opens up file explorer and goes to their Document folder does the OP see the folder named Arduino?

When the OP opens the Arduino folder is there another folder named "libraries"'?

In the libraries folder does the OP see a folder named "MCP4XXXX" or some representative name of the library?

Try this

  • In the IDE File/Examples open one of the examples for the library that you have just installed
  • with the example sketch open in the IDE use Sketch/Show Sketch Folder
  • Windoes File Explorer will open
  • click on the end of the path in Windows File Explorer that has just opened to highlight it. Copy the path and paste it here
  • it should look something like this C:\Users\Bob2\Documents\Arduino\libraries\AccelStepper\examples\Random

I inferred from this

that you had given up on digipots, if not the whole project.

Did you never get the code you had working with the digipots?

If you get the library to work, will that solve the issues you came against that had nothing to do with getting the digipots to function as they are intended to do?

a7

UKHeliBob the library I installed is called ArdumaxMCP41xxx Driver. When I went to the IDE File/Examples, there were no examples for this library. When I checked the library out before I installed it, there were no examples. That is what I would really like---examples.
alto777 Yes, I got the MCP4231 working with the red and green LEDs. All the examples I see with digipots do the same thing---they run LEDs from off to full on and loop. I am wanting to see examples of where the digipots are set at a voltage, or resistance, I set in code. I am not interested in running the LEDs from off to full on and repeating that. In fact, I am not interested in running LEDs with digital pots at all. I am interested in controlling op amps---in particular the gain of the op amp.
You ask if I get the library to work, will that solve the issues you came against. Maybe--- if I can see some examples other than code for running LEDs from off to full on and repeating. That is ALL the examples I have found with digital pots. Knowledge about code has everything to do with getting the digipots to function as they are intended to do? A person can learn a great deal by viewing examples. Again alto777---- all the examples I have seen with digipots involve running LEDs from off to full on and looping that. I need to see some different examples and I am not finding them. alto777 can you refer some examples other than digipots used with LEDs?

If you learned just a bit more about programming, you might see that getting the digipots to work, with or without a library, could be banked and exploited in any way that you want.

Your working code in the other thread you have could easily be turned into a function that would take a number and set the a digipot.

Whatever you do on top of that is not for us to provide examples for… it's a digipot, it works according to the data sheet. You have in your hands the means to manipulate it and…

now you have to figure out what you can do with it, which may or not be anything that will help your original project along.

a7

I agree alto777. I will start working on code. Thanks!

Unfortunately, some library authors don't bother to include example sketches with their libraries. That happens to be the case with the library you picked, so it is normal and expected that you didn't find any listed under the File > Examples menu in the Arduino IDE.

There is some documentation in the library's readme though:

that includes some example code:

#include <MCP41xxx.h>

MCP41xxx dac(10);

void setup(void)
{
  dac.begin();
}

void loop(void)
{
  dac.analogWrite(0, millis());
}