Engine rpm.

HELP ME! Not a programmer. Just a hobbie tinkerer.

New Arduino user. I have an rpm code that work very well thanks to EASY!.
Used his rpm code to get rpm of v-8 engine works well! Thanks EASY. I’m trying to use a button push to read rpm and store it in eeprom and also
use this value in the code to perform my if/else statement’s.

At the button push I’d like to store present rpm in as readrpm.
Have no clue how to do this, but this is what I have so far.
Any help is greatly appreciated.

#include <EEPROM.h>               //don't know how to go from here with this?

volatile int tachCount = 0;
long time;
long rpm = 0;
int outpin = 10; 
int ledpin = 13;                       // output visual  
const int buttonPin = 3;          // the number of the pushbutton pin, Copied from debounce at playground...
int buttonState;                     // the current reading from the input pin
int lastButtonState = LOW;      // the previous reading from the input pin
long lastDebounceTime = 0;     // the last time the output pin was toggled
long debounceDelay = 50;       // the debounce time; increase if the output flicker 
long readrpm = 0;                  // button push to store rpm as readrpm

void setup()
attachInterrupt(0, tachPulse, RISING);
time = millis();

void loop()
{pinMode (ledpin, OUTPUT);
pinMode(2, INPUT);
pinMode (outpin, OUTPUT); 

if (rpm  <readrpm)
{digitalWrite (outpin, HIGH);
{digitalWrite (outpin, LOW);
if (rpm  <readrpm)
{digitalWrite (ledpin, HIGH);
{digitalWrite (ledpin, LOW);

  //Runs every 1/4 second
  if (millis() - time >= 250)
    // rpm = number of interrupts counted in 250ms
    //  *4 to make per second
    //  *60 to make per minute
    //  /2 for 2 pulses per rotation (4 cylinder)or 4 for 4 pulses per rev. (8 cyl.)
    //  /10 for some reason???
    rpm = (((tachCount*4)*60)/4)/10; 
if (buttonState, HIGH) //button push to write rpm as readrpm 

   {write (rpm, readrpm?);}   // readrpm value 

esle (buttonState, LOW)       //to read rpm store as readrpm in eeprom & also place it in the (rpm < readrpm);

   {read (?);}   //Help.

    //delay (50);
    tachCount = 0;
    time = millis();


void tachPulse()

Correction to post.

Thanks to EASTY for the rpm code! Not EASY..

I guess you have read http://arduino.cc/en/Reference/EEPROM in the reference section?

Ok you want to store the current value of rpm in readrpm, and also in the EEPROM for the next time you power up…

  // the code is similar for write and for read..
    long rpmReadFromEEPROM = 0 ; // a variable to hold what has been read  from the EEPROM.
    long rpm ;
    int byte_index ; // a counter to move over the bytes
    for (byte_index = 0 ; byte_index < sizeof(rpm) ; byte_index++) // for each byte in the rpm variable
        // to write the rpm value do the next line
        EEPROM.write(byte_index, (rpm >> (8*byte_index)) & 0xff) ; // select each byte and write it.

        // to read rpmReadFromEEPRM do the next line.
        rpmReadFromEEPROM |= (EEPROM.read(byte_index) << (8*byte_index)); // read the byte out and combine again 

Great. Thanks for the input. Will try to use it! If Need more help I be back here again.