I have little skill in programming skills, but I have been able to fumble my way with forum help and sketch examples to control a stepper motor running some gears and belts to rotate a disc. Ive modified Cheapstepper_simple.ino to count steps, stop at 180 degrees rotation, wait 20 minutes then rotate back the opposite direction. Due to sloppy gears, slipping, and whatnot, the system, over time, will slowly move off of 180 degrees with each rotation. I think a sensor approach vs counting steps will work better.
Is there a simple sketch example I can modify to sense, (say with a Hall Effect sensor), the rotating disk location (vs count steps)?
The rotation angle of the disk can be measured using a shaft encoder, available commercially in countless configurations.
Most shaft encoders are relative, meaning you have to set the zero position at power up. Absolute shaft encoders are available, but are much more expensive.
I looked at shaft encoders. The shaft encoder hardware solution will not work in my existing mechanical configuration. I can easily add a magnet to the rotating disk and have it sensed to stop the rotation, I hope, more consistently than my sloppy mechanical gearing and belts.
A Hall Effect sensor could be used to count complete shaft or disk rotations.
The State Change Detection example built into the Arduino IDE does that to count button presses, which are functionally and electrically equivalent to Hall Effect sensor outputs.
If you think about this approach, you will realize that it can only indicate when your object has already passed that point, whereas the stepper motor can be stopped at the point you want.
I would program the sketch to stop the motor when it detects state change at the sensor. as long as is consistent why would that not work? As I said, the mechanical system is sloppy and counting stepper motor steps will slowly change the 180 degree location of the disk and does not work.
. It works fine for me at 18 RPM. Rotates fine. Im using GT2 pulleys and geared belt. Its slips. Its sloppy. It is what it is and will not be changed. I only need to sense whenever it hits 180 degrees and I will stop the motor and it will be good enough for me.