ive tried everything... it just doesent want to work! I started making my own code to test it and see if it workks, and i'm getting some results. I've succesfully made 4 colors on one row that can light up every button the same color by delaying them very fast. And also for some reason, the second digital pot won't work, even though i change slave select to 10... Does anything else need to be changed, or can everything stay the same except for slave select?
thanks again....
-big93
edit:
ok, so i tinkered around some more, and now i have half the buttons light up diffrent colors. Ill post a pic or maybe a vid on the tube.
I also half figured out why i couldent get the second digital pot working....:
i unhooked all the color wires from the second pot when i was re checking everything...
i only found it out when one wire accidentally touched a resistor, and the whole row 3rd row turned blue.
and 1 more thing...
in the first version you complained of the very very lack of bright intense colors, but ever since i removed the transistors AND the resistors connecting to the arduino pins, the arduino dident break, and the colors are so bright i can bring them into fairly bright rooms and still see them well....
hopefully when i hook up the other 2 rows, the current doesent add up and murder my arduino...
if you know this will happen, please warn me
and i have a youtube video up, showin it, also read the description because i purposely slow down the refresh rate...:
http://youtube.com/watch?v=tlI9Vino97E&feature=RecentlyWatched&page=1&t=t&f=bok ok, only 1 more edit...
so i keep trying to make the second digital pot work, but it seems not to be working...
i hooked up the rest of the rgb led's the same way i hooked up the first digital pot, and i changed the slave select on my arduino code and the same thing thats been happening on the first side, is not happening on the other. I'll post the code further down... So i'm guessing that exactly the same thing should happen on the other side, but it doesent seem to do anything similarly... It doesent even have a refresh rate like the first pot, cuz when i slow it down with the pot, it doesent stop.
weird
can you see my code and tell me if you see anything faulty please?
code:
#define DATAOUT 11//MOSI
#define DATAIN 12//MISO - not used, but part of builtin SPI
#define SPICLOCK 13//sck
#define SLAVESELECT 10//ss*** it is either 10, or 18
byte potpin = 0;
byte r1=0;
byte g2=1;
byte g1=2;
byte b2=3;
byte b1=4;
byte r2=5;
byte res1=255;
byte res2=255;
byte res3=255;
byte res4=255;
byte res5=255;
byte res6=255;
char spi_transfer(volatile char data)
{
SPDR = data; // Start the transmission
while (!(SPSR & (1<<SPIF))) // Wait the end of the transmission
{
};
return SPDR; // return the received byte
}
void setup()
{
byte i;
byte clr;
pinMode(DATAOUT, OUTPUT);
pinMode(DATAIN, INPUT);
pinMode(SPICLOCK,OUTPUT);
pinMode(SLAVESELECT,OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
digitalWrite(SLAVESELECT,HIGH); //disable device
// SPCR = 01010000
//interrupt disabled,spi enabled,msb 1st,master,clk low when idle,
//sample on leading edge of clk,system clock/4 (fastest)
SPCR = (1<<SPE)|(1<<MSTR);
clr=SPSR;
clr=SPDR;
delay(10);
for (i=0;i<6;i++)
{
write_pot(i,255);
}
}
byte write_pot(int address, int value)
{
digitalWrite(SLAVESELECT,LOW);
//2 byte opcode
spi_transfer(address);
spi_transfer(value);
digitalWrite(SLAVESELECT,HIGH); //release chip, signal end transfer
}
void loop()
{
potpin = analogRead(0)/5+1;
digitalWrite(7, LOW);
write_pot(r2, 0);
write_pot(g1, 0);
delay(potpin);
digitalWrite(7, HIGH);
digitalWrite(6, LOW);
write_pot(g1, 255);
write_pot(r1, 0);
write_pot(r2, 255);
write_pot(b2, 0);
delay(potpin);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
write_pot(r1, 255);
write_pot(b2, 255);
write_pot(g1, 0);
write_pot(b2, 0);
write_pot(r2, 0);
delay(potpin);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
write_pot(b1, 0);
write_pot(g2, 0);
write_pot(g1, 0);
write_pot(b2, 255);
write_pot(r2, 255);
delay(potpin);
digitalWrite(4, HIGH);
write_pot(g2, 255);
write_pot(b1, 255);
write_pot(g1, 255);
}
looks ok to me.. and it works on the first digital pot....