I am using the attachInterrupt()
function in Arduino Uno to recognize the end of stroke of an actuator. Usually the test is used with if()
, however the actuator cycle is very fast and the recognition by this means becomes complicated. With this I opted to use attachInterrupt()
, however I do not know if in the case of interruption I should use a pull-down resistor at the input. Could anyone tell me if he has this need?
Currently the system looks like the image.
Piece of code:
attachInterrupt(digitalPinToInterrupt(interruptPin2), EndCourse2, FALLING);
attachInterrupt(digitalPinToInterrupt(interruptPin3), EndCourse3, FALLING);
void EndCourse2()
{
digitalWrite(12,LOW);
btnpressed2=0;
}
void EndCourse3()
{
if(btnpressed2==0)
{
digitalWrite(12,HIGH);
CounterAT2++;
}
btnpressed2=1;
}