Go Down

Topic: Measuring Frequency on Arduino Mega 2560 (Read 1 time) previous topic - next topic

smarcus3

This was very difficult to find.

To do this you need to download the library at ... http://www.pjrc.com/teensy/td_libs_FreqCount.html

Pin 47 is used to measure the frequency on the 2560 mega and cannot be changed. Here is sample code that will work with the arduino.

Code: [Select]

/* FreqCount - Example with serial output
* NEED TO USE D IO PIN 47 FOR FREQUENCY INPUT FOR 2560 MEGA!!!!!!!!
* http://www.pjrc.com/teensy/td_libs_FreqCount.html
*
* This example code is in the public domain.
*/
#include <FreqCount.h>

void setup() { 
  Serial.begin(9600);
  FreqCount.begin(1000);
}

void loop() {
  if (FreqCount.available()) {
    unsigned long count = FreqCount.read();
    Serial.println(count);
  }
 
   }


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!

Arduino
via Egeo 16
Torino, 10131
Italy