Added arduino libs
هذا الالتزام موجود في:
35
libraries/PID/examples/PID_Basic/PID_Basic.ino
Normal file
35
libraries/PID/examples/PID_Basic/PID_Basic.ino
Normal file
@@ -0,0 +1,35 @@
|
||||
/********************************************************
|
||||
* PID Basic Example
|
||||
* Reading analog input 0 to control analog PWM output 3
|
||||
********************************************************/
|
||||
|
||||
#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
|
||||
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(PIN_INPUT);
|
||||
Setpoint = 100;
|
||||
|
||||
//turn the PID on
|
||||
myPID.SetMode(AUTOMATIC);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Input = analogRead(PIN_INPUT);
|
||||
myPID.Compute();
|
||||
analogWrite(PIN_OUTPUT, Output);
|
||||
}
|
||||
|
||||
|
المرجع في مشكلة جديدة
حظر مستخدم