Hello, I am trying to use PID control and AccelStepper library in Arduino. I want to set up a programming when the temperature reaches 50C, stepper motor start to run, but when the temperature is below 50C, then the stepper motor stops. Since I am using RAMP 1.4 board as the extension board, the pinouts are related with the board. The code runs fine just with the PID temperature control part, however, when I put the code with AccelStepper in, the error shows: "exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560." even I am just compiling the code without trying to upload the code. Can anyone help me to check out the code please?
The code is as attached:
//For RAMPS 1.4
#include <PID_v1.h>
#include <AccelStepper.h>
#define X_STEP_PIN 54
#define X_DIR_PIN 55
#define X_ENABLE_PIN 38
#define X_MIN_PIN 3
#define X_MAX_PIN 2
#define SENSOR A3
#define HEATER 10
double targettemp, temp, heat;
double Kp=2, Ki=5, Kd=1;
PID myPID(&temp, &heat, &targettemp, Kp, Ki, Kd, DIRECT);
AccelStepper stepper(1,54,55);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
targettemp=50;
myPID.SetMode(AUTOMATIC);
stepper.setMaxSpeed(50);
stepper.setSpeed(50);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.print("\n Temperature sensor is = ");
Serial.print(5.0100analogRead(SENSOR)/1024);
Serial.print(" and heat output = ");
Serial.print(heat);
temp = 5.0100analogRead(SENSOR)/2014;
myPID.Compute();
analogWrite(HEATER, heat);
delay(200);
if(SENSOR>=50){
Stepper.runSpeed();
}
else{
}
delay(500);
}
Stepper_Temperature.ino (997 Bytes)