Peak RPM Recall.

I have a tachometer project that I need to add a peak RPM recall feature with a momentary button. How would I go about this?

I'm using a Pro Mini and a Sparkfun serial seven segment display. Thanks in advance.

int peakRpm;

if(rpm > peakRpm)
  peakRpm = rpm;

if(digitalRead(button) == LOW)
   // code to display peakRpm

Thank you sir. l will try that. So would I just do a digitalwrite to pin to display when a button is pressed?

Need to see your code to answer that. be sure to use code tags.


Mongo408: Thank you sir. l will try that. So would I just do a digitalwrite to pin to display when a button is pressed?

An indicator to show that the reading is peak reading would be a good idea, although most tachos that have this feature usually only display the value while the button is pushed. Tom.... :)

Attaching Code.

FreqTach3.ino (15 KB)

Ok this is the section of code you will need to work with.

void loop() {

  // *********************************** Check the Engine Speed *********************************** //

  if ( newEngineSpeedData )
    engineSpeed = getRpm();

    if ( engineSpeed < minCalSpeed)
      engineSpeed = minCalSpeed;

    if ( engineSpeed > maxCalSpeed )
      engineSpeed = minCalSpeed; // <<<<<<<<<<<< minCalSpeed should be changed to maxCalSpeed here!!

    //delay( 2 );

    Serial.print("RPM: ");
    Serial.println( engineSpeed );

    // Magical sprintf creates a string for us to send to the s7s.
    //  The %4d option creates a 4-digit integer.

    char rpmString[5];
    sprintf(rpmString, "%4d", (int) getRpm());

    mySerialPort.print (rpmString)
    ;     delay(rDelay);


First I found a small error that wouldn’t be noticed unless the engine was redlined.

    if ( engineSpeed > maxCalSpeed )
      engineSpeed = minCalSpeed; // <<<<<<<<<<<< minCalSpeed should be changed to maxCalSpeed here!!

Darn, Something has come up and I’ll have to wait till after work to finish this.
Maybe someone else can show you how to do this before I return.

It's quite alright. There's no rush. I'll check back later. Thank you again.

It’s been a killer 14 hr day at work, so I am in no mood to try to teach.
I’ve added the changes(untested) you wanted and marked them with: //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

I put the button on pin 11 and it should be connected like this: pin 11 >>>> Button >>>> Ground
currently it should display peak rpm only while holding the button. to reset peak rpm you will have to reset or power off the arduino.

Have you tested this code yet?? can you post a link to where you got it??
As I was working on it I noticed that there were several things that were never finished.
These seem like they were just extra features and not something essential, Hopefully but I’m not sure as I cannot test it though it does compile.

Hope this works for you.
Time for me to crash, Ill check in in the morning.


FreqTach3.ino (16.8 KB)

Just curious, I noticed in your code that you are using a Schmidt trigger and an optocoupler; may I ask why? Using the schmidt trigger with the proper capacitor/resistor combination is a great signal filter. An optocoupler is usually a design used in place of the Schmidt trigger for tachometer applications where there is perfect ground isolation. I'm just having a hard time understanding why you would use both.

Either one will filter the signal really well. Electromagnetic interference, however is an entirely different beast to tackle. What types of engines will this tach work for? Are you shielding the connections to the PCB/Arduino? My apologies if this goes a little off topic, my curiosity got the better of me.

Thanks, Laggy

Hutkikz - Thank you for taking the time to look at this. Yes this code has been tested prior to this. I actually have a working tachometer in my truck right now using this code. I'm still customizing it little by little as I go.

Mr_Laggy - I am using a Schmitt Trigger H11L1 and I have a resistor, capacitor, and diodes in front of the H11L1. That's simply because the tach that I have now with this configuration is connected to the negative side of the coil and it's noisy. I used to have an MSD with a tach output but I can't seem to keep one alive, so I no longer use one. Ultimately the best case scenario would be the MSD with a tach output signal or a digital signal. Right now it will work on a V8 but that math for RPM could be changed for any engine. No need to apologize for the curiosity, I'm by no means a know-it-all. If I was, I wouldn't be here.

Glad I could help, Let me know if it works. I found your other thread and youtube vid. Very Cool!! :sunglasses:

Hope you don't mind if I save your code as there is Tach project in my future as well('80 GMC Cabellero).

Glad you like it the video! :)

Yes, please feel free to use the code for your project. I hope it's helpful.