Hi
I have a process that requires a stepper to move 40 steps in each loop.
the way I have it set up the arduino adds 40 steps to the target position each time through the loop the moves to the target position.
this works great until it gets to 32 thousand and then it can’t add the 40 more for some reason.
I think I read somewhere this was the biggest number arduino could store in one byte or something (can’t remember specifics)
so how can i work around this?
Thanks
*/
#include <LiquidCrystal.h>
#include <AccelStepper.h>
AccelStepper stepper(1,3,2); //stepper pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);//lcd pins
//initialise Outputs
const int buttonPin = 22;
const int pumped = 48;
const int lowered = 47;
int rotate = 25; //valve 5 blue t7
int raise = 26; //valve 4 green t6
int vice = 1; //valve 3 yellow t5
int cap = 12; // valve 2 orange t4
int pump = 4; // red t3
int led = 13;
float stepperAngle = 0; //variable for stepper angle
int count = 0; //Steps count
int buttonState=0;
int time=1000;
int button=A0;
int whichButton=0;
void setup()
{
pinMode(rotate, OUTPUT);
pinMode(raise, OUTPUT);
pinMode(vice, OUTPUT);
pinMode(cap,OUTPUT);
pinMode(pump, OUTPUT);
pinMode(led,OUTPUT);
stepper.setMaxSpeed(30);
stepper.setAcceleration(100);
stepper.setCurrentPosition(0);
lcd.begin(16,2);
lcd.clear();
lcd.print("STEPS");
lcd.setCursor(0,1);
lcd.print("ANGLE");
}
void loop()
{
if (analogRead(button)>1100)
{
stepperAngle=(0);
}
digitalWrite (cap,HIGH);
digitalWrite (vice, HIGH);
digitalWrite(pump, HIGH);
delay(200);
digitalWrite(pump,LOW);
delay(400);
digitalWrite (cap,LOW);
delay(700);
digitalWrite(raise, HIGH);
delay(150);
digitalWrite(raise, LOW);
digitalWrite(vice, LOW);
delay(time); //change this value to adjust the speed
stepperAngle = stepperAngle+40;
stepper.runToNewPosition(stepperAngle);
delay(200);
count=count+1;
lcd.setCursor(7,0);
lcd.print(count);
lcd.setCursor(7,1);
lcd.print(stepperAngle);
lcd.setCursor(12,1);
lcd.print(whichButton);
}
Filling_Machine_with_stepperand_lcd2.ino (1.58 KB)