Last active
July 19, 2019 04:01
-
-
Save Tbruno25/b7e7a2993ed6175fc6068e75384e26c4 to your computer and use it in GitHub Desktop.
Medium Article
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
void loop() | |
{ | |
if (!digitalRead(2)) | |
{ | |
CAN0.readMsgBuf(&rxId, &len, rxBuf); | |
delay(5); | |
if ((rxId == buttonId) && (rxBuf == buttonData)) | |
{ | |
buttonPress++; | |
if (buttonPress == 1) | |
{ | |
startMillis = millis(); | |
} | |
if (buttonPress == 2) | |
{ | |
endMillis = millis(); | |
if (endMillis - startMillis <= 1000) | |
{ | |
buttonPress = 0; | |
//Do something! | |
} | |
else | |
{ | |
buttonPress--; | |
} | |
} | |
} | |
if ((buttonPress == 1) && (millis() - startMillis > 1000)) | |
{ | |
buttonPress--; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment