当前位置:   article > 正文

arduino 控制无刷电机_arduino控制无刷电机测速

pid v1.h

#include <Servo.h>

#include <PID_v1.h>

Servo myservo; // create servo object to control a servo

int potpin = 0; // analog pin used to connect the potentiometer

float val; // variable to read the value from the analog pin

float vall;

float valls;

int scode=0;//speed test

float speeds;

unsigned long oldtime = 0, newtime;

double Setpoint,Input,Output;

double kp=2;

double ki=5;

double kd=0;

PID myPID(&Input,&Output,&Setpoint,kp,ki,kd,DIRECT);

int switchs;

void setup()

{Serial.begin(9600); // 初始化串口通信

attachInterrupt(0, code, CHANGE); // 设置码盘外部中断

myservo.attach(9);

Setpoint=80;

myPID.SetMode(AUTOMATIC);}

void loop()

{ newtime = millis();

if(newtime-oldtime>1000)

{

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/运维做开发/article/detail/890498
推荐阅读
相关标签
  

闽ICP备14008679号