SPI - 595 Arduino Sketch
SPI - 595 Arduino Sketch
#include <SPI.h>
void setup ()
{
//pinMode (LATCH, OUTPUT); // sets pin 10 as OUTPUT, since it plays the SS-Slave Select role
DDRB |= (1<<DDB2); // sets PB2, pin 10, as OUTPUT, since it plays the SS-Slave Select role
SPI.begin ();
// below settings reccomended for IDE 1.6.0 and above
SPI.beginTransaction (SPISettings (4000000, MSBFIRST, SPI_MODE0)); // 4 MHz clock, MSB
first, Mode 0
//Serial.begin(115200);
/*
sei(); // Enables Global Interrupts
SPCR |= (1<<SPIE); // sets SPI Interrupt Enable bit
*/
//SPI.attachInterrupt();
} // end of setup
void loop ()
{
c++; // incremets the byte one bit at the time
//digitalWrite (LATCH, LOW);
PORTB &= ~(1<<PB2); // puts SS pin 10 LOW
SPI.transfer (c);
PORTB |= (1<<PB2); // puts SS pin 10 HIGH
//digitalWrite (LATCH, HIGH);
//Serial.println(c);
delay (1000);
} // end of loop
-1-