#include "fan speeeed.h" int fan_speed(float voltage_value){ init_millis() sei(); float fan_speed; float t = 0; float past_time = 0; float start_time = 0; int old_value = 0; int f; if (voltage_value > 300 && old_value < 300){ start_time = init_millis() t =(start_time - past_time); past_time = start_time; } voltage_value = old_value; f = ((1/t)*1000); fan_speed = (f*60)/2; return fan_speed; } ISR(PORTB_PORT_vect) { static int counter = 0; if (counter >=5){ PORTB.OUT ^= 0x0F; counter = 0; } PORTB.INFLAFS = PIN2_bm; }