Last active
May 7, 2020 17:56
-
-
Save govaniso/f072e443aaa9f9f7993f313bbb1f0d17 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
int pinSW = D0; | |
int pinDT = D1; | |
int pinCLK = D2; | |
int valorSW; | |
int valorDT; | |
int valorNuevoCLK; | |
int valorAnteriorCLK; | |
void setup() { | |
Serial.begin(9600); | |
pinMode(pinSW, INPUT); | |
pinMode(pinDT, INPUT); | |
pinMode(pinCLK, INPUT); | |
valorAnteriorCLK = digitalRead(pinCLK); | |
} | |
void loop() { | |
valorNuevoCLK = digitalRead(pinCLK); | |
valorDT = digitalRead(pinDT); | |
valorSW = digitalRead(pinSW); | |
if(valorNuevoCLK != valorAnteriorCLK) { | |
if(valorAnteriorCLK == 1) { | |
Serial.print("Valor CLK = "); | |
Serial.print(valorNuevoCLK); | |
Serial.print(", Valor DT = "); | |
Serial.print(valorDT); | |
if(valorDT == 1) { | |
Serial.println(" => Giro en sentido Antihorario."); | |
} else { | |
Serial.println(" => Giro en sentido Horario."); | |
} | |
} | |
valorAnteriorCLK = valorNuevoCLK; | |
} | |
delay(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment