using a photo interrupt sensor as a gate limiter
i rebuilding mighty mule gate opener, electronics burned out. new @ arduino thing
and having hard time photo interrupt sensor. ( keyestudio , work fine).
i trying write learn loop , can't 2 limit switches in opener because of space requirements. unit had photo sensor on , want use count number of
times opening in wheel comes around turn off motor when open or
closed. think figured major portion of out. counting of slots in wheel
i having trouble. there kinds of examples of rpm sketches. nothing can find has
a simple counter stores value in value , resets sensor zero.
this cam not seem right. @ first "if" statement.
does record number of times sensor switched ?
code:
void opengatelearn () {
digitalwrite(opengate, high); //turn on gate using h-bridge
digitalwrite(pwm, 245); // send power level motor
if(digitalread(photosensor == low) {
sensorvalue++;
serial.println("sensorvalue"); //prints debugging
serial.println(sensorvalue); //prints debugging
}
if (openlimit == low) { //looks open limit button pressed
digitalwrite(opengate, low); //stops gate opening
digitalwrite(pwm, 0); //shuts off power motor
opensensorvalue = sensorvalue; //sends sensorvalue opensensorvalue read later
sensorvalue = 0; // resets sensorvalue zero
}
}
and having hard time photo interrupt sensor. ( keyestudio , work fine).
i trying write learn loop , can't 2 limit switches in opener because of space requirements. unit had photo sensor on , want use count number of
times opening in wheel comes around turn off motor when open or
closed. think figured major portion of out. counting of slots in wheel
i having trouble. there kinds of examples of rpm sketches. nothing can find has
a simple counter stores value in value , resets sensor zero.
this cam not seem right. @ first "if" statement.
does record number of times sensor switched ?
code:
void opengatelearn () {
digitalwrite(opengate, high); //turn on gate using h-bridge
digitalwrite(pwm, 245); // send power level motor
if(digitalread(photosensor == low) {
sensorvalue++;
serial.println("sensorvalue"); //prints debugging
serial.println(sensorvalue); //prints debugging
}
if (openlimit == low) { //looks open limit button pressed
digitalwrite(opengate, low); //stops gate opening
digitalwrite(pwm, 0); //shuts off power motor
opensensorvalue = sensorvalue; //sends sensorvalue opensensorvalue read later
sensorvalue = 0; // resets sensorvalue zero
}
}
code: [select]
if(digitalread(photosensor == low)
this true when input is low several increments whilst low. instead, want count how many times input becomes low in statechangedetection example in ide
Arduino Forum > Using Arduino > Programming Questions > using a photo interrupt sensor as a gate limiter
arduino
Comments
Post a Comment