Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define inputPin 3
- unsigned long mSec;
- unsigned long oldMillis;
- unsigned char oldInput;
- void setup() {
- // put your setup code here, to run once:
- pinMode( inputPin, INPUT_PULLUP);
- Serial.begin(115200);
- oldMillis= millis();
- oldInput= digitalRead( inputPin);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- unsigned char inputNow= digitalRead( inputPin);
- if (oldInput!= inputNow) {
- unsigned long millisNow= millis();
- mSec= millisNow- oldMillis;
- oldMillis= millisNow;
- oldInput= inputNow;
- Serial.print( mSec);
- Serial.write( "\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement