Created
August 16, 2017 03:58
-
-
Save eagereyes/2eb774dcdf80112b51137d0afb0b69b7 to your computer and use it in GitHub Desktop.
Simple test program to shift out some bits to measure the difference between different Atmel chips and SPI vs. shiftOut()
This file contains hidden or 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
// Simple test program to shift out some bits to measure the difference between | |
// different Atmel chips and SPI vs. shiftOut() | |
#include <SPI.h> | |
/* for Feather and Arduino Uno | |
#define RCLK_PIN 9 // latching pin for the shift registers to show values at their outputs | |
#define DATA_PIN MOSI | |
#define CLK_PIN SCK | |
// */ | |
//* for attiny85 | |
#define RCLK_PIN 4 // latching pin for the shift registers to show values at their outputs | |
#define DATA_PIN 1 | |
#define CLK_PIN 2 | |
// */ | |
// pick one of these | |
//#define SHIFTMODE | |
#define SPIMODE | |
void setup() { | |
pinMode(RCLK_PIN, OUTPUT); | |
#ifdef SHIFTMODE | |
pinMode(DATA_PIN, OUTPUT); | |
pinMode(CLK_PIN, OUTPUT); | |
shiftOut(DATA_PIN, CLK_PIN, LSBFIRST, 0); | |
#endif | |
#ifdef SPIMODE | |
SPI.begin(); | |
SPI.beginTransaction(SPISettings(16000000, LSBFIRST, SPI_MODE0)); | |
#endif | |
} | |
uint8_t num = 0x00; | |
void loop() { | |
digitalWrite(RCLK_PIN, LOW); | |
#ifdef SHIFTMODE | |
shiftOut(DATA_PIN, CLK_PIN, LSBFIRST, num); | |
#endif | |
#ifdef SPIMODE | |
SPI.transfer(num); | |
#endif | |
digitalWrite(RCLK_PIN, HIGH); | |
num += 1; | |
delay(200); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment