Pages: [1]   Go Down
Author Topic: Measuring Frequency on Arduino Mega 2560  (Read 965 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
/* 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);
  }
 
   }

Logged

Pages: [1]   Go Up
Jump to: