sorry about not being clear what I am trying to measure RPM using a QRD1114 and I can get record how many times the axle goes round but i need the count to reset to 0 every second so i can work out the RPM this is my program:
#include "mbed.h"
#include "TextLCD.h"
class Counter {
public:
Counter(PinName p18) : _interrupt(p18) {
_interrupt.rise(this, &Counter::increment);
}
void increment() {
_count++;
}
int read() {
return _count;
count_reset
}
private:
InterruptIn _interrupt;
volatile int _count;
};
Counter counter(p18);
int main() {
TextLCD lcd(p24, p25, p26, p27, p28, p29, p30); // rs, rw, e, d0, d1, d2, d3
while(1) {
lcd.printf("Count so far:\n %d\n", counter.read());
}
}
Hi i am making a program with a counter, i was wondering how you can reset it