13. hall_effect
#define ledPin 13
#define hall_effect 2
unsigned long time;
int pulse = 0;
int rpm;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(hall_effect, INPUT);
attachInterrupt(0, count_pulse, RISING);
Serial.begin(9600);
}
void loop(){
if(millis() - time > 1000){
time = millis() ;
rpm = pulse*60/2;
Serial.print(rpm);
Serial.println(" RPM");
pulse=0;
}
}
void count_pulse(){
pulse++;
}