Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- volatile int rpmcount = 0;
- int rpm = 0;
- unsigned long lastmillis = 0;
- void setup(){
- Serial.begin(9600);
- attachInterrupt(0, rpm_fan, FALLING);
- }
- void loop(){
- if (millis() - lastmillis == 1000){
- detachInterrupt(0);
- Serial.print(analogRead(0));
- Serial.print(',');
- Serial.println(rpmcount);
- rpmcount = 0;
- lastmillis = millis();
- attachInterrupt(0, rpm_fan, FALLING);}
- }
- void rpm_fan(){
- rpmcount++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement