Skip to content

Instantly share code, notes, and snippets.

@Tbruno25
Last active July 19, 2019 04:01
Show Gist options
  • Save Tbruno25/b7e7a2993ed6175fc6068e75384e26c4 to your computer and use it in GitHub Desktop.
Save Tbruno25/b7e7a2993ed6175fc6068e75384e26c4 to your computer and use it in GitHub Desktop.
Medium Article
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