I have a sketch I am trying to get working properly. Basically I have a mega with a LCD Keypad shield a L298 motor control shield with a 28BYJ-48 stepper motor.
This setup is to rotate a variable capacitor from 0 - 180 degrees which it does without many problems and comes to a stop at 0 and 180 and will only rotate in the opposite direction e.g if rotated to 180 it will only rotate to 0.
However, when the arduino is turned on it goes through initialisation and then rotates approx 22 degrees which then messes up the position of the capacitor ( it makes the arduino think that the 22 degree position is now 0) So if I reset multiple times the capacitor eventually goes to 180 but the arduino thinks it’s 0. What I need to happen on startup is nothing and the stepper motor does not rotate until I tell it to AND importantly that the position of the stepper is remembered and displayed on the LCD. Or the motor will go to either 180 or 0 on startup
Is this possible or should I look at other means?
capacitor_control.ino (4.85 KB)