Created
May 2, 2018 03:27
-
-
Save nasser/ac726dc14fe39db14a0c27586aed4b92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// based on https://gist.github.com/nrdobie/8193350 | |
#include <SPI.h> | |
#define LOAD_PIN 7 | |
void setup() { | |
// Set load pin to output | |
pinMode(LOAD_PIN, OUTPUT); | |
// Reverse the SPI transfer to send the MSB first | |
SPI.setBitOrder(MSBFIRST); | |
// Start SPI | |
SPI.begin(); | |
digitalWrite(LOAD_PIN, LOW); | |
SPI.transfer(0x0F); | |
SPI.transfer(0x01); | |
digitalWrite(LOAD_PIN, HIGH); | |
digitalWrite(LOAD_PIN, LOW); | |
SPI.transfer(0x0F); | |
SPI.transfer(0x00); | |
digitalWrite(LOAD_PIN, HIGH); | |
digitalWrite(LOAD_PIN, LOW); | |
SPI.transfer(0x09); | |
SPI.transfer(0x00); | |
digitalWrite(LOAD_PIN, HIGH); | |
digitalWrite(LOAD_PIN, LOW); | |
SPI.transfer(0x0A); | |
SPI.transfer(0x00); | |
digitalWrite(LOAD_PIN, HIGH); | |
digitalWrite(LOAD_PIN, LOW); | |
SPI.transfer(0x0B); | |
SPI.transfer(0x00); | |
digitalWrite(LOAD_PIN, HIGH); | |
digitalWrite(LOAD_PIN, LOW); | |
SPI.transfer(0x0C); | |
SPI.transfer(0x01); | |
digitalWrite(LOAD_PIN, HIGH); | |
} | |
void loop() { | |
digitalWrite(LOAD_PIN, LOW); | |
SPI.transfer(0x01); | |
SPI.transfer(0x04); | |
digitalWrite(LOAD_PIN, HIGH); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment