So I am trying to test what will eventually be a Arduino controlling 3 110V motors that are currently controlled by an analog pot. But more on that later.
I am trying to test out using a digital pot (never have before) and am running into some issues with tutorials I have found online. For now, I want to control a LED with the digital pot (Spec Sheet) so that the LED fades in and fades out in a continuos loop.
Here is the tutorial I followed. It uses a different chip model but it seems from the pot I am using that the pins are the same. (I could be wrong?)
I double and triple checked the wiring and it matches below.
Here is the code I am running (slightly modified from the tutorial, also tried the tutorial code)
#include <SPI.h>
byte address = 0x11;
int CS= 10;
int i=0;
void setup()
{
pinMode (CS, OUTPUT);
SPI.begin();
}
void loop()
{
for (i = 0; i <= 128; i++)
{
digitalPotWrite(i);
delay(10);
}
delay(500);
for (i = 128; i >= 0; i--)
{
digitalPotWrite(i);
delay(10);
}
}
int digitalPotWrite(int value)
{
digitalWrite(CS, LOW);
SPI.transfer(address);
SPI.transfer(value);
digitalWrite(CS, HIGH);
}
As a result of the two above, I have an LED that stays lit (at about 50% it seems) and does not fade in/out at all.
Being relatively new to wiring and EE in general, is there a better way to replicate an analog pot without using a digital pot? Can I just use PWM to control it? Why would the LED be just staying lit?
Thanks!