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()
{Serial.begin(9600);
attachInterrupt(0, tachPulse, RISING);
time = millis();
}
void loop()
{pinMode (ledpin, OUTPUT);
pinMode(2, INPUT);
pinMode (outpin, OUTPUT);
if (rpm <readrpm)
{digitalWrite (outpin, HIGH);
}
else
{digitalWrite (outpin, LOW);
}
if (rpm <readrpm)
{digitalWrite (ledpin, HIGH);
}
else
{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.
Serial.println(rpm);
//delay (50);
tachCount = 0;
time = millis();
}
}
//}
void tachPulse()
{
++tachCount;
}