Cover image
Try Now
2019-05-28

Steuern Sie ein Microchip MCP4XXX Digital Potentiometer mit einem Arduino.

3 years

Works with Finder

3

Github Watches

21

Github Forks

58

Github Stars

arduino-mcp4xxx

Arduino library for controlling Microchip's MCP4XXX range of SPI controlled digital potentiometers.

Supported Devices

The supported chips are designated as follows:

MCP 4 X Y Z
      │ │ │
      │ │ └── (Z) Wiper Configuration
      │ │         1 = Potentiometer, 2 = Rheostat
      │ │
      │ └──── (Y) Memory Type / Resolution
      │           3 = 7-bit RAM, 4 = 7-bit EEPROM, 5 = 8-bit RAM, 6 = 8-bit EEPROM
      │
      └────── (X) Number of pots
                  1 or 2

This encompasses: MCP4131, MCP4151, MCP4231, MCP4251, MCP4132, MCP4152, MCP4232 and MCP4252.

SPI connection on MCP4X1X

Note that the MCP41X1 chips multiplex SDI and SDO on a single pin. To use these chips with a standard SPI interface as on the Arduino you will need to connect the shared SDI/SDO pin on the pot to the Arduino's MISO pin, then bridge the MISO pin to the MOSI pin with a resistor (3k9 resistor seems to work well).

Installation

  • Download the library (a list of available versions is here)
  • Exit the Arduino IDE
  • Copy mcp4xxx.h and mcp4xxx.cpp files to a folder named mcp4xxx in your Arduino libraries folder
  • Restart the Arduino IDE, the library should now be available by including mcp4xxx.h as per the example below

More information is available under the section titled "Manual Installation" on the libraries page of the official Arduino website.

Example

#include <SPI.h>
#include <mcp4xxx.h>

using namespace icecave::arduino;

MCP4XXX* pot;

void setup()
{
    // Construct an instance of the MCP4XXX to manage the digipot.
    // The first parameter is the pin number to use for 'chip select' (CS), if you are
    // using the default SPI CS pin for your Arduino you can simply omit this parameter.
    pot = new MCP4XXX(49);
}

void loop()
{
    // Move the wiper to the lowest value
    pot->set(0);

    // Move the wiper to the highest value
    pot->set(pot->max_value());

    // Increment the wiper position by one
    pot->increment();

    // Decrement the wiper position by one
    pot->decrement();
}

The MCP4XXX class supports the full range of commands available on the MCP4XXX range of devices, for more information please see the API documentation in the header file.

Known Issues / Caveats

  • Does not support entire 4XXX range, notably absent is support for I2C and quad-pot devices.
  • Only tested with MCP4151, which does not have a hardware shutdown pin.

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • 林乔安妮
  • A fashion stylist GPT offering outfit suggestions for various scenarios.

  • https://reddgr.com
  • Delivers concise Python code and interprets non-English comments

  • 田中 楓太
  • A virtual science instructor for engaging and informative lessons.

  • pontusab
  • Die Cursor & Windsurf -Community finden Regeln und MCPs

  • av
  • Führen Sie mühelos LLM -Backends, APIs, Frontends und Dienste mit einem Befehl aus.

  • jae-jae
  • MCP -Server für den Fetch -Webseiteninhalt mit dem Headless -Browser von Dramatikern.

  • ravitemer
  • Ein leistungsstarkes Neovim -Plugin für die Verwaltung von MCP -Servern (Modellkontextprotokoll)

  • patruff
  • Brücke zwischen Ollama und MCP -Servern und ermöglicht es lokalen LLMs, Modellkontextprotokoll -Tools zu verwenden

  • 1Panel-dev
  • 🔥 1Panel bietet eine intuitive Weboberfläche und einen MCP -Server, um Websites, Dateien, Container, Datenbanken und LLMs auf einem Linux -Server zu verwalten.

  • Mintplex-Labs
  • Die All-in-One-Desktop & Docker-AI-Anwendung mit integriertem Lappen, AI-Agenten, No-Code-Agent Builder, MCP-Kompatibilität und vielem mehr.

  • GeyserMC
  • Eine Bibliothek für Kommunikation mit einem Minecraft -Client/Server.

  • appcypher
  • Awesome MCP -Server - eine kuratierte Liste von Modellkontext -Protokollservern für Modellkontext

  • chongdashu
  • Aktivieren Sie KI -Assistenten -Clients wie Cursor, Windsurf und Claude -Desktop, um Unreal Engine durch natürliche Sprache mit dem Modellkontextprotokoll (MCP) zu steuern.

  • awslabs
  • AWS MCP -Server - Spezielle MCP -Server, die AWS -Best Practices direkt in Ihren Entwicklungsworkflow bringen

    Reviews

    2 (1)
    Avatar
    user_r08w28dk
    2025-04-17

    I've been using the arduino-mcp4xxx library by jmalloc and it's fantastic. The documentation is clear, and the integration with Arduino projects is seamless. It allows precise control over MCP4XXX digital potentiometers, which is exactly what I needed for my latest project. Highly recommend checking it out on GitHub!