enhance coding style
This commit is contained in:
@ -5,16 +5,20 @@
|
||||
|
||||
#include <PID_v1.h>
|
||||
|
||||
#define PIN_INPUT 0
|
||||
#define PIN_OUTPUT 3
|
||||
|
||||
//Define Variables we'll be connecting to
|
||||
double Setpoint, Input, Output;
|
||||
|
||||
//Specify the links and initial tuning parameters
|
||||
PID myPID(&Input, &Output, &Setpoint,2,5,1, DIRECT);
|
||||
double Kp=2, Ki=5, Kd=1;
|
||||
PID myPID(&Input, &Output, &Setpoint, Kp, Ki, Kd, DIRECT);
|
||||
|
||||
void setup()
|
||||
{
|
||||
//initialize the variables we're linked to
|
||||
Input = analogRead(0);
|
||||
Input = analogRead(PIN_INPUT);
|
||||
Setpoint = 100;
|
||||
|
||||
//turn the PID on
|
||||
@ -23,9 +27,9 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
Input = analogRead(0);
|
||||
Input = analogRead(PIN_INPUT);
|
||||
myPID.Compute();
|
||||
analogWrite(3,Output);
|
||||
analogWrite(PIN_OUTPUT, Output);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user