树莓派+L9110S电机模块

电机模块

VCC接2.5-12V电压,GND接地
A1,B1接GPIO22,GPIO23
A2,B2接GPIO24,GPIO25

OA1 OB1 接直流电机2个引脚,无方向
OA2 OB2 接直流电机2个引脚,无方向

#include 
#include 

//前进
void up() {

    pinMode(22, OUTPUT);
    pinMode(23, OUTPUT);
    pinMode(24, OUTPUT);
    pinMode(25, OUTPUT);

    digitalWrite(22, HIGH);
    digitalWrite(23, LOW);
    digitalWrite(24, HIGH);
    digitalWrite(25, LOW);
    delay(3000);
    digitalWrite(22, LOW);
    digitalWrite(23, LOW);
    digitalWrite(24, LOW);
    digitalWrite(25, LOW);
}

//后退
void down() {

    pinMode(22, OUTPUT);
    pinMode(23, OUTPUT);
    pinMode(24, OUTPUT);
    pinMode(25, OUTPUT);

    digitalWrite(22, LOW);
    digitalWrite(23, HIGH);
    digitalWrite(24, LOW);
    digitalWrite(25, HIGH);
    delay(3000);
    digitalWrite(22, LOW);
    digitalWrite(23, LOW);
    digitalWrite(24, LOW);
    digitalWrite(25, LOW);
}

//停止
void stop(){

    digitalWrite(22, LOW);
    digitalWrite(23, LOW);
    digitalWrite(24, LOW);
    digitalWrite(25, LOW);

}

你可能感兴趣的:(树莓派)