c# - Controlling a DC motor with a sensor -
i'm controlling dc motor blocking sensor , open when send command it. need dc motor stop when not blocking sensor anymore. should mention methods called native dll. believe there no way me position of motor. in documentation, doesn't getting position.
i tried create loop keep hitting motor until sensor unblocked should stop motor. unfortunately, think motor goes fast when sensor unblocked it's late check condition , when sensor being blocked again. tried slow down motor , didn't change anything. have solution on how can make motor run stop when sensor unblocked? have code.
int boardtwo; int motoronespeed, motoronedir, motortwospeed, motortwodir; int inputshutter = 0; boardtwoshutter = 2; motoronespeed = 0; motoronedir = mhk_stopped; motortwospeed = 195; motortwodir = mhk_forward; motor_getdigitalinputs(boardtwo, ref inputshutter); while (inputshutter > 0) { motor_setdcmotors(boardtwo, motoronespeed, motoronedir, motortwospeed, motortwodir); } motortwodir = mhk_stopped; motor_setdcmotors(boardtwo, motoronespeed, motoronedir, motortwospeed, motortwodir);
Comments
Post a Comment