Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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