Go Down

Topic: Need help using the digital potentiometer MCP4018 5k (Read 564 times) 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()
{
  Wire.begin();
  Serial.begin(9600);
}

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.beginTransmission(pot_address);
    Wire.write(rval); //
    Wire.endTransmission();
    Serial.print(" sent - ");
    Serial.println(rval, HEX);
    delay(dt);
  }
}

void loop()
{
  potLoop();
}


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!

Jamie.

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
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy