int led_high = 13; // this LED will show user if a string's pitch is too highint led_ok = 12; // this LED will show user if a string's pitch is correctint led_low = 11; // this LED will show user if a string's pitch is too low

// After the string input has been idle for a while, we take the average of a number of cross counts that were in bound.if (idle_timer == 10000){Serial.println("AVG AVG LOOK HERE AVG AVG");average_val = avg_cross / divide_by;Serial.println(average_val);

// If the tuning is off by a questionably high amount, count it as an error in reading and do not turn the peg.// Otherwise tune the peg for a period of time. This time depends on how far off the read average is.if (pitch_diff < 20)for(long i = 0; i < pitch_diff * 36000; i++){digitalWrite(servoPin, HIGH); // start the pulsedelayMicroseconds(15); // pulse widthdigitalWrite(servoPin, LOW); // stop the pulse}}

// If the tuning is off by a questionably high amount, count it as an error in reading and do not turn the peg.// Otherwise tune the peg for a period of time. This time depends on how far off the read average is.if (pitch_diff < 20)for(long i = 0; i < pitch_diff * 270000; i++){digitalWrite(servoPin, HIGH); // start the pulsedelayMicroseconds(2); // pulse widthdigitalWrite(servoPin, LOW); // stop the pulse}}

You have a function, ISR(). Every function needs to have a return type. Yours does not.

If your function does not return a value, its return type should be void.

Would a function used as a ISR function ever be anything but a void function? As the original code that was interrupted didn't call the function how could the returned value be of value, and might that screw up the stack upon return if it was other then a void that returned a value?

Would a function used as a ISR function ever be anything but a void function? As the original code that was interrupted didn't call the function how could the returned value be of value, and might that screw up the stack upon return if it was other then a void that returned a value?

Typically, there are well-defined signatures for callback functions, like ISR. A function that does not have that signature will make the compiler unhappy, and nobody likes an unhappy compiler.

The compiler is checking that the number of values popped off the stack on return is equal to the number of bytes pushed onto the stack prior to the return. That the morons (I mean developers) on the Arduino team decided that no compiler warnings are to be displayed makes it hard to see that this is done.

Would a function used as a ISR function ever be anything but a void function? As the original code that was interrupted didn't call the function how could the returned value be of value, and might that screw up the stack upon return if it was other then a void that returned a value?

Typically, there are well-defined signatures for callback functions, like ISR. A function that does not have that signature will make the compiler unhappy, and nobody likes an unhappy compiler.

The compiler is checking that the number of values popped off the stack on return is equal to the number of bytes pushed onto the stack prior to the return. That the morons (I mean developers) on the Arduino team decided that no compiler warnings are to be displayed makes it hard to see that this is done.

Thanks for that explantion, not that most of it didn't zoom over my head? I was thrilled the first time a got a ISR function to work at all in one of my sketches (it was of course a void function ), so even the thought that such a ISR function could even possibly return a value, let alone be usable, kind of blows my mind. I don't think I will be undertaking 'callback functions' any time soon.

If you do any event-driven programming, you have to use callbacks. On a form, for example, you define a button, and register a function to be called when the button is pressed.

attachInterrupt() is a mechanism for registering a callback. The second argument is the function to be called when the conditions are right (i.e. when the interrupt occurs).

Typically, ISR's do not return values, but there are other cases where a callback function IS supposed to return a value.

I could post an example of a callback function, callback registration function, and callback invocation code that I wrote recently, but it has nothing to do with Arduino (more like a paycheck), so I won't. The whole purpose was to let one class define the color of a cell in a table while the other class managed the display and other properties of the table. Since the table class was designed to be used in many places, the using application needed to have control over the cell color which is based on a property of the cell. Some applications might want cells with the error set to be red, while others might want the cell to be purple. Having the table class define the color would have prevented that from happening. Having the class that instantiated the table register a function to be called when the cell color was needed made it possible.

thanks for helping me out guys.really appreciate it.now the compiler seems to work but my motor still not functioning.there is a lot of maybes and i think its related to timer in the atmega and the pins.still trying though