Stepper motor nema 34 revolution project

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;
}
}

This forum section is for help with questions about motor/power code that you wrote, or are using.

To have someone write code for you, ask the moderator to move your post to the Jobs and Paid Collaborations forum section.

Where is the code we are supposed to attack?

So you want us to figure out what hardware to use and write the code based on your rather vague requirements?

What is your part in your project?

Here you go: FlexiStepper.h

And maybe https://learn.adafruit.com/character-lcds

@Railroader

#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.

[quote="ghufi, post:6, topic:994215, full:true"]
#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;
}
}

@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.

You are welcome.

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.
code tags new

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.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.