void encoder(const int piste_A, const int piste_B)
{
attachInterrupt(0,direction_speed, RISING);
}
What is this function supposed to be doing ? It is supplied 2 parameters that are never used in the function and attaches an interrupt each time through the loop() function when it only needs to be attached once in setup()
Then, later on, in the middle of the ISR you attach the same interrupt to another routine 20 times
Later in the same ISR you attempt to print a variable that is not defined even though Serial.print() does not work in an ISR because interrupts are disabled.
I totally agree that function void encoder is useless.
And vitesse i just forgot to change it to speed when posting the code.
And about attach interrupt (0,increment,RISING) inside loop while
It's just to know how many rising i have during period t to calcul the speed.
Sorry for my english. :*
And I'm still noob in programming. :*
Could you explain more .???
I think function interrupt will test if there is RISING and if it's true it will
Increment "a" Then i will multiply It by the angle of each hole
To Get the angle of rotation of my wheel then to get the distance I will apply distance =angle*(diameter/2)
Then speed =distance/t.
t I will count it using millis .
So to get the period To cross the distance interrupted should be inside
Loop "while"