Arduino-GPIO
General Purpose Input/Output (GPIO) library for Arduino
ShiftIn.ino
Go to the documentation of this file.
1 #include "GPIO.h"
2 #include "SRPI.h"
3 #include "benchmark.h"
4 
6 #define DATA_PIN 12
7 #define CLOCK_PIN 13
8 
9 void setup()
10 {
11  Serial.begin(57600);
12  while (!Serial);
13 
14  // Set pin mode
15  pinMode(DATA_PIN, INPUT);
16  pinMode(CLOCK_PIN, OUTPUT);
17 
18  // Set benchmark baseline
19  BENCHMARK_BASELINE(1000);
20 }
21 
22 void loop()
23 {
24  uint8_t value;
25 
26  BENCHMARK("1. Arduino core shiftIn", 1000) {
27  value = shiftIn(DATA_PIN, CLOCK_PIN, LSBFIRST);
28  }
29 
30  BENCHMARK("2. SRPI input operator", 1000) {
31  srpi >> value;
32  }
33 
34  Serial.println();
35  delay(2000);
36 }
Definition: SRPI.h:31
#define CLOCK_PIN
Definition: ShiftIn.ino:7
Software::Serial< BOARD::D0 > Serial
Definition: ShiftIn.ino:6
SRPI< LSBFIRST, BOARD::D1, BOARD::D2 > srpi
Definition: ShiftIn.ino:7
void loop()
Definition: ShiftIn.ino:24
#define BENCHMARK(msg, scale)
Definition: benchmark.h:52
#define BENCHMARK_BASELINE(scale)
Definition: benchmark.h:34
#define DATA_PIN
Definition: ShiftIn.ino:6
void setup()
Definition: ShiftIn.ino:11