An arduino writes values from 0-255 on Potentiometer 1 (I'm having some trouble with Pot 0, see below), and the chip then writes that value to the Pot, creating a voltage divider that fades in/out an LED! It's progress, and it's a positive sign for creating a library!
I am, however, having problems with Pot 0. For some reason, When I try sending the command bit addressing Pot 0 (B00010001), it simply doesn't work. That pot appears to be stuck on 127 (5k resistance). But, when I send the command for Pot 1 (B00010010), that pot functions fine, exactly as I expect.
Also oddly, when I send the command to write both pots (B00010011), neither work! This is very confusing.. Here's the code I'm currently using if anyone wants to give some advice:
#define sLatch 2
#define sClock 3
#define sData 4
#define commandData B00010001 // command = write to pot 0
byte data;
void setup()
{
pinMode(sLatch, OUTPUT);
pinMode(sClock, OUTPUT);
pinMode(sData, OUTPUT);
}
void loop()
{
for (int i = 0; i<256; i++) { digitalWrite(sLatch, LOW); shiftOut(sData, sClock, MSBFIRST, commandData); shiftOut(sData, sClock, MSBFIRST, i); digitalWrite(sLatch, HIGH); delay(5); } for (int i = 255; i>-1; i--) {
digitalWrite(sLatch, LOW);
shiftOut(sData, sClock, MSBFIRST, commandData);
shiftOut(sData, sClock, MSBFIRST, i);
digitalWrite(sLatch, HIGH);
delay(5);
}
}
Thanks for looking, I'll check back when I get something new happening!
-Stephen
No comments:
Post a Comment