Hi, i am working on a project, on pressing start button want to stop stepper motor after completing 120 revolutions, revolutions should be visible on display screen.
After 120 revolutions, if we press start button again it should start again stop after 120 turns.
Please help in complete code.
If someone can help if possible i also want +,- button if want to give specific revolutions to motor,
#include <wire.h>
#include<liquidcrystal_I2C.h>
int x = 0;
int input = A0;
int state = 0;
liquidcrystal_I2C lcd(0x27, 16, 2);
void setup ()
{
lcd.init();
lcd.init();
lcd.backlight();
lcd.setcursor(0, 1);
lcd.print(" tPI");
lcd.setcursor (0, 1);
lcd.print(x);
lcd.print(" =turn ");
}
void loop()
}
int counter = digitalread(A0);
if (state == 0)
{
switch (counter) {
case 1 : state = 1; lcd.setcursor (0,1); x=x+1; lcd.print(x); break;
case 0 : state = 0;break;
}
}
i am able to count turns. but i want to stop stepper motor after 120 rounds. and reset again. if i press start button again, it should start from 1 and again stop after 120 rounds. if you can help to add some code here.
@groundFungus thanks for your zero benefit comment. i already know about hardware which is wired properly, and enough coding i have done. so please don't think so much about my part in project.
if you are unable to help someone, don't devalue them.
Read the forum guidelines to see how to properly post code and some information on how to get the most from this forum. Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.
You can go back and fix your original post by highlighting the code and clicking the </> in the menu bar.
What does the code actually do?
I see no code for a stepper. You have told us nothing of the stepper motor or the stepper driver.
If you try to write the code and have trouble, we will help, but we will not do it for you.