digital pot

Ok. I am new to this whole serial communication. I have a digital pot and it does increments up to 255. I need some help writing some code. 1. Each time I hit a button it increments up one 2. I also need it to write to the serial console on the computer to tell me where i am from 0 -255

Can this be done?

Mike

It can be done, just as you described.

Without any details of what the hardware is or how you have connected it, etc, you are probably not going to get much help. If you have already written code then post that too.

Without any details of what the hardware is or how you have connected it, etc, you are probably not going to get much help.

There's a pretty good chance, though, that if you Google "arduino xxxx" where xxxx is the model of your pot, you'll get some code to get you started. Often the suppliers like Adafruit and Sparkfun will have sample code.....

I am using an mini and the pot is ad5204. I know how to read a push button but just not sure how to code the serial communication to increment.

firstly you need to keep track of the number you have between 0-255, and every time that you detect the button you increment the variable and then send that to the pot. The serial comms are SPI, which is the same as you would use for a 595 shift register, of which there are LOTS of examples usually associated with setting LED patterns. The application may be different, but the technique is exactly the same. The circuits will also be identical (clock, data and enable/latch digital pins for the interface).

Here's some code that I wrote a long time ago to set LEDs

//The 74HC595 using a protocol called SPI (for more details http://www.arduino.cc/en/Tutorial/ShiftOut)
//Which has three pins
#define  DATA_PIN  10   
#define  CLOCK_PIN  9
#define  LATCH_PIN  8

void setup()
{
  // We set the three control pins to outputs
  pinMode(DATA_PIN, OUTPUT);
  pinMode(CLOCK_PIN, OUTPUT);  
  pinMode(LATCH_PIN, OUTPUT);  
}

void updateLEDs(byte value, boolean bReverse, int nPause)
// Handle the interface to the 74HC595 to write the 8 bits of the byte  
// Optionally invert the bit string and then delay at the end
{
  if (bReverse) value = ~value;

  digitalWrite(LATCH_PIN, LOW);  //Pulls the chips latch low
  shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, value); //Shifts out the 8 bits to the shift register
  digitalWrite(LATCH_PIN, HIGH);   //Pulls the latch high displaying the data
  
  if (nPause != 0) delay(nPause);
}

Loads of Google hits for "arduino ad5204"

Here’s a tutorial on using the MCP4162 and the datasheet.

MCP4162-103E-P.pdf (1.55 MB)