okay got a tpic6b595 wired on a breadboard to turn on leds.
decoupling cap included, seperate resistor of each led
trying to use the SPI method.
Arduino tpic6b595
P13 12
p12 3
p10 13
8 vcc
9 gnd
here is the sketch
// SPI commands will be used to send the data out
#include <SPI.h> // bring in SPI library
#define SS 10 // output latch for cathodes shift register. Pin D10 needs to be an output for SPI.
byte dataArray[]= {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}; // load up some initial data
// dataArray[0] = B00000001
// dataArray[1] = B00000010
// dataArray[2] = B00000100
// dataArray[3] = B00001000
// dataArray[4] = B00010000
// dataArray[5] = B00100000
// dataArray[6] = B01000000
// dataArray[7] = B10000000
int x=0;
void setup()
{
pinMode (SS, OUTPUT);
SPI.begin(); // commits 11,12,13 for hardware SPI transfer. Make sure shift registers have 0.1uF/100nF on their VCC pins to ground.
SPI.setBitOrder(LSBFIRST);
SPI.setClockDivider(SPI_CLOCK_DIV8);
SPI.setDataMode(SPI_MODE1);
}
void loop()
{
// turn off leds
digitalWrite (SS, LOW);
SPI.transfer(0);
digitalWrite (SS, HIGH);
delay(1000);
for(x=0;x<7;x++)
{
// turn on one led, all others off for apox. half a second
digitalWrite (SS, LOW);
SPI.transfer(dataArray[x]);
digitalWrite (SS, HIGH);
delay(500);
}
} // end void loop
Now its turning on and off leds in groups, turning on one after the other, sequence ever other one, just seems to do whatever it feels like except what I want it to do. And this WITHOUT changing any of the code first and upload it.
What am I doing wrong???
I tryed changing SPI mode, Clock rate, change code to read just ONE dataArray cell over and over, change delays, wiggleing wires , nothing seems to work ....
HELP!!!