long previus_millis=0; byte counter, whidth=0; void setup() { Serial.begin(9600); Serial.println("Zero cross tester"); attachInterrupt(0, calculation, RISING); // настроить порт прерыванияна 0, это 2й цифровой пин по возрастающему фронту //attachInterrupt(0, calculation, FALLING); // настроить порт прерыванияна 0, это 2й цифровой пин по спадающему фронту //attachInterrupt(1, calculation, RISING); // настроить порт прерыванияна 1, это 3й цифровой пин по возрастающему фронту //attachInterrupt(1, calculation, FALLING); // настроить порт прерыванияна 1, это 3й цифровой пин по спадающему фронту } void calculation() { counter++; whidth+=(millis()-previus_millis); previus_millis=millis(); if (counter==10) { counter=0; Serial.println(whidth/10); whidth=0; } } void loop() { // put your main code here, to run repeatedly: }