Skip to content

Instantly share code, notes, and snippets.

@tlindner
Created September 27, 2020 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlindner/2512842dae8c1483d8e0b9a02ced83bc to your computer and use it in GitHub Desktop.
Save tlindner/2512842dae8c1483d8e0b9a02ced83bc to your computer and use it in GitHub Desktop.
#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