hi thanks for your replies on that link Gammon Forum : Electronics : Microprocessors : Interrupts there is a lot of stuff on that website to get your head wrapped around lol i have come up with this compiles fine but somethings telling me im missing something here?
volatile int rpmcount;
int sensorState = 0;
unsigned int rpm;
unsigned long timeold;
ISR (PCINT2_vect)
{
// handle pin change interrupt for D0 to D7 here
} // end of PCINT2_vect
void setup ()
{
Serial.begin(9600);
// pin change interrupt (example for D0)
PCMSK2 |= _BV (PCINT16); // want pin 0
PCIFR |= _BV (PCIF2); // clear any outstanding interrupts
PCICR |= _BV (PCIE2); // enable pin change interrupts for D0 to D7
}
void loop(){
if(rpmcount>=5) {
rpm=(60000*rpmcount)/(8*(millis()-timeold)); //the 8 changes to 4 if 4 magnets are used.
timeold = millis();
//Serial.println(rpmcount,DEC);
rpmcount = 0;
Serial.println(rpm,DEC);
}
}
p.s i dont wont the led output