Created
December 14, 2015 16:30
-
-
Save michaelsarduino/5d7940f3ae61e8229ea3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 sensor_pin = 8; | |
int shockVal = HIGH; | |
unsigned long letzter_schock; // millis bei letztem schock | |
int shockTime = 250; | |
void setup () | |
{ | |
Serial.begin(9600); | |
pinMode (sensor_pin, INPUT) ; | |
} | |
void loop () | |
{ | |
shockVal = digitalRead (sensor_pin) ; //lesen des Sensors | |
if ((shockVal == LOW )&&( millis() > (letzter_schock + shockTime)) ) // wenn shock registriert und laenger als 250 millisekunden | |
{ | |
letzter_schock = millis(); | |
Serial.println("Schock registriert!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment