Created
September 27, 2020 06:47
-
-
Save tlindner/2512842dae8c1483d8e0b9a02ced83bc 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
#define LED 13 | |
#define SCS 0 | |
#define RW 1 | |
void setup() { | |
pinMode(LED, OUTPUT); | |
pinMode(SCS, INPUT); | |
pinMode(RW, INPUT); | |
digitalWrite(LED, HIGH); | |
} | |
void loop() { | |
unsigned int scs; | |
unsigned int previous_SCS = HIGH; | |
unsigned int write_count = 0; | |
unsigned int read_count = 0; | |
while (1) { | |
scs = digitalRead(SCS); | |
if (previous_SCS == HIGH) { | |
if (scs == LOW) { | |
if (digitalRead(RW)) { | |
read_count++; | |
digitalWrite(LED, LOW); | |
} | |
else { | |
write_count++; | |
digitalWrite(LED, HIGH); | |
} | |
} | |
} | |
previous_SCS = scs; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment