/************************************************************************************************** * * PulseCountAsync * * Version: 1.0.0 - September 2009 * Author: Etienne Ribeiro / tutorial assistant caad / eribeiro[at]ethz.ch * Supervisor: Christoph Wartmann / chair for caad - ETH Zürich / wartmann[at].arch.ethz.ch * * Desc: Counts pulses on a digital pin over a given period asynchronously. * ***************************************************************************************************/ // var int onboardLED = 13; // onboardLED: 13 = Arduino, 48 = Wiring int PulsePin = 10; // PulsePin: Pin to read pulse from. int Intervall = 1000; // Intervall: ms to mesure from given pin. // setup void setup () { // LED (2 * blink) pinMode(onboardLED, OUTPUT); digitalWrite(onboardLED, HIGH); delay(200); digitalWrite(onboardLED, LOW); delay(200); digitalWrite(onboardLED, HIGH); // Serial Serial.begin(9600); // Print Serial.print ("PulseCountAsync started on Pin "); Serial.print (PulsePin); Serial.print (", Intervall "); Serial.print (Intervall); Serial.println (); Serial.println (); } // loop void loop() { int val = PulseCounstAsync (PulsePin, Intervall); if (val >= 0) { Serial.print ("Value "); Serial.println (val); } }