MCP4231, using only one of the two digital potentiometers

I am trying to get one of the two digital potentiometers in the MCP4231 IC to operate a green LED. The Arduino code should cycle the green LED from off to full on, then cycle the green LED to off. This program should loop the code making the Green LED go off and on.
I did not hook up any wires to the second potentiometer in the MCP4231 IC.
I am not getting anything out of the green LED, it never comes on. The code runs and there are no errors. I have checked my wiring connections several times. I think something in the code is making it not work.
One question I do have is this: The MCP4231 IC has a MOSI connection and a MISO connection. I have tried with the MISO connected and not connected and the green LED will not light either way. I notice on the MCP4131 IC---the single version of the MCP4231 they do not connect to the MISO when controlling a LED in the same way.
Below is my code, something is wrong because it does not work, and there are no error messages.

byte addressGreenLED=B00000000;
int CS=10;
void setup()
{
pinMode (CS,OUTPUT); // put your setup code here, to run once:
SPI.begin();
}
void loop()
{
for(int j = 0; j <=128; j++) // put your main code here, to run repeatedly:
{
digitalPotWriteGreen(j);
delay(100);
}
delay(2000);
for (int j = 128; j >= 0; j--)
{
digitalPotWriteGreen(j);
delay(100);
}
delay (2000);
}
int digitalPotWriteGreen(int valueGreen)
{digitalWrite(CS,LOW);
SPI.transfer(addressGreenLED);
SPI.transfer(valueGreen);
digitalWrite(CS,HIGH);
}

Ok, is see one mistake. I did not do this on the start of the code #include <SPI.h>

It probably will not work as described. Post a schematic, not a frizzy thing to show how you connected this. The pot will not drive a LED directly which is what I am reading in your description.

Still does not work.
Thanks for replaying gilshultz. I had the MCP4231 hooked up to the two individual pots contained in the IC. The two pots drove both LEDs. One red LED would come on then go off. Then a green LED would come on then go off. Then the red LED would come on then go off. Then the green LED would come on and go off. This process looped. So I know the pots will drive LEDs. I have simply eliminated the RED LED in the code.

Here is my how I hooked everything up. I left pins 5,6,and 7 on the MCP4231 not connected to anything. Pins 10,9, and 8 are connected to my green LED.

Read the complete data sheet, then re-read page 5 and the notes it contains. Also if you study the data sheets for the LEDs you are using you will find they are current not voltage dependent devices. There is a book called "Electronics for Dummies" that or many others like it would be a good place to start. Note: I did not name the book but it is good for beginners.

I suppose the question arises…
If you have spare PWM output pins available, why bother with the digital pot idea at all ?

Thanks lastchancename. I don't want to use PWM, I want to use SPI

Meh, ok.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.