pwm控制直流电机转速流程图_Arduino:直流电机PWM调速

PWM直流电机调速(代码):

int i=0;

void Forward();

void Back();

void Turn_left();

void Turn_right();

void Speed_up();

void Slow_down();

void setup() {

// put your setup code here, to run once:

pinMode(9,OUTPUT);

pinMode(10,OUTPUT);

pinMode(5,OUTPUT);

pinMode(6,OUTPUT);

}

void loop() {

// put your main code here, to run repeatedly:

Forward();

Back();

Turn_left();

Turn_right();

Speed_up();

Slow_down();

}

void Forward(){

//you guys must understand which pin connect to VCC,which pin connect to GND

digitalWrite(9,HIGH);

digitalWrite(10,LOW);

digitalWrite(5,HIGH);

digitalWrite(6,LOW);

delay(4000);

}

void Back(){

digitalWrite(9,LOW);

你可能感兴趣的:(pwm控制直流电机转速流程图)