is http://gammon.com.au/interrupts: pagrindineje funkcijoje siulo naudoti noInterrupts (); .......... interrupts (); Arduino turiu, bet su pertraukimais dar nezaidziau. > volatile unsigned int c = 0; // counter > volatile boolean dir = 1; // direction > > int fwdrevPin = 9; > > void setup() { > attachInterrupt(0, tacho, CHANGE); > pinMode(fwdrevPin, OUTPUT); > } > > void loop() { > noInterrupts (); > if (c > 623){ > > // Serial.println(c); > > dir = !dir; // Switch direction > c = 0; // Reset counter > if (dir==0) { > analogWrite(fwdrevPin, 140); > } > else { > int t = 128 - torque; > analogWrite(fwdrevPin, 100); > } > } > > > interrupts (); > } > > void tacho() > { > c++; > }