Can an arduino measure this fast?

Hey everyone, I now have all the parts I need to read the RPM of something and display it on an 8x2 LCD, however I don't know if the arduino can measure as fast as I need.

The target max RPM is 3050, or, just under 51 times per second. I am wondering if an arduino can compare the readout from a gauss sensor (if the output is greater than x than mark that as the magnet having been passed by) so that I can just count how many times it goes by in one second and display the RPM on the LCD without much of a delay, Ideally instantaneously would be good, an update speed of twice per second would be perfect although reading the RPM exactly might be finicky.

Is it possible to do something this fast?

Alright so I made this, just basic, I need a way to count how many times the “state” variable changes to one per second to get the RPM, I’ll have to find out how to count that.

#define NOFIELD 505L    // Analog output with no applied field, calibrate this

// Uncomment one of the lines below according to device in use A1301 or A1302
// This is used to convert the analog voltage reading to milliGauss
#define TOMILLIGAUSS 1953L  // For A1301: 2.5mV = 1Gauss, and 1024 analog steps = 5V, so 1 step = 1953mG
// #define TOMILLIGAUSS 3756L  // For A1302: 1.3mV = 1Gauss, and 1024 analog steps = 5V, so 1 step = 3756mG

int state;

void setup() 
  state = 0;
  pinMode(13, OUTPUT);

void DoMeasurement()
// measure magnetic field
  int raw = analogRead(0);   // Range : 0..1024

  long compensated = raw - NOFIELD;                 // adjust relative to no applied field 
  long gauss = compensated * TOMILLIGAUSS / 1000;   // adjust scale to Gauss

  if (gauss < -500)  state = 1;
  else               state = 0;

void loop() 
    if (state == 1){
    digitalWrite(13, HIGH);
    } else {
      digitalWrite(13, LOW);

Why not just use something like this?

analogRead(Ax) is good for about 10,000 samples per second. Taking readings at 50 times/second is possible. digitalWrite - will you be looking at that output with an oscilloscope? If using an LED, it will just appear to be always on after about 20 Hz, just appearing somewhat brighter as the frequency increases. digitalWrite is also kinda slow; you may want to use direct port manipulation, or look into fastdigitalwrite.

You can, you just need to be careful if you read the data out. For example...Serial.print() takes a good amount of clock cycles to do.....

You are looking at the wrong kind of Hall sensor. The A1301 and A1302 are analog sensors, used for measuring a magnetic field. For measuring the RPM of something, you should use a digital RPM sensor. I would use a US1881 with 2 magnets mounted on the rotating object. One should have the N pole facing the US1881 when it passes. The other should be diametrically opposite the first, and have its S pole facing the US1881 when it passes.

If you search the Arduino forum for "rpm counter", you will find plenty of example code for this arrangement.