Go Down

Topic: Need help using the digital potentiometer MCP4018 5k (Read 1 time) previous topic - next topic


Hi everyone,

Thanks in advance, I'm having trouble with understanding how this tiny chip works. We have a RC transmitter (ct6b) and have removed one of the 5v pots from the device and want to replace it with a digital one (MCP4018 5k) to control the rx output.

The code i am using is:

Code: [Select]
// Example 20.1

int dt = 2000; // used for delay duration
byte rval = 0x00; // used for value sent to potentiometer
#include "Wire.h"
#define pot_address 0x2F // each I2C object has a unique bus address, the MCP4018 is 0x2F or 0101111 in binary

void setup()

void potLoop()
// sends values of 0x00 to 0x7F to pot in order to change the resistance
// equates to 0~127
  for (rval=0; rval<128; rval++)
    Wire.write(rval); //
    Serial.print(" sent - ");
    Serial.println(rval, HEX);

void loop()

I have wired it up and I left with two wires going spare, the Wiper and the A or INPUT.  My question is am I heading in the right direction altogether and if so how would i wire it up.

Image of chip diagram/pinouts: http://i1.wp.com/tronixstuff.com/wp-content/uploads/2010/10/mcp4018sch1.jpg?resize=500%2C363
REF: http://tronixstuff.com/2010/10/20/tutorial-arduino-and-the-i2c-bus/

Many thanks!



Nevermind, the chip was placed the wrong way round. Works a treat though, we can control the rx output digitally now.

Cheers. ps dont use your eyes to judge pin 1 on a 2x2mm chip :)

Go Up