Skip to content

Instantly share code, notes, and snippets.

@iH8c0ff33
Last active December 13, 2015 10:38
Show Gist options
  • Save iH8c0ff33/e2ba263565b809d6dabc to your computer and use it in GitHub Desktop.
Save iH8c0ff33/e2ba263565b809d6dabc to your computer and use it in GitHub Desktop.
uint8_t prPin = 0;// Pin Fotoresistenza
uint8_t prTrigger = 50;// Se minore di questo trigger
// Programma
bool start = true;
unsigned long startTime = 0;
uint8_t count = 0;
void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600);
delay(500);
digitalWrite(13, HIGH);
delay(250);
digitalWrite(13, LOW);
}
void loop() {
if (start) {
startTime = millis();
start = false;
} else {
if (analogRead(prPin) > prTrigger) {
Serial.print(++count);
Serial.print(": ");
Serial.print((millis()-startTime)/1000.0);
Serial.println();
start = true;
delay(200);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment