Go Down

Topic: Using timers and counters. (Read 930 times) previous topic - next topic


I've got a project where I want to count a signal from a shock sensor for 5 seconds.

Push the button
delays 3 seconds
Outputs a buzzer
starts 5 second timer
counts number of inputs from sensor
buzzes again at 5 seconds
outputs number of hits to lcd.

I don't expect anyone to do it for me but I'd sure appreciate it if someone would point me in the right direction.

Thanks guys


Lots of ways to implement a counter:
   int i = 0;
   i = i + 1;  // Increase counter by 1
   i += 1;     // Increase counter by 1
   i++;        // Increase counter by 1

For a timer:
   unsigned long startTime = millis();

  if (millis() - startTime > 5000)  // 5-second timer has expired
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp



Would you know of any project on-line that uses this method that I could modify for my use?


Well, the BlinkWithoutDelay example (File->Examples->2.Digital->BlinkWithoutDelay) would be a good place to start.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131