本文是通过Arduino对马达进行PWM波的输出从而使风扇转动的源码
constintmotorIn1=9; constintmotorIn2=10; voidsetup() { // put your setup code here, to run once:pinMode(motorIn1,OUTPUT); pinMode(motorIn2,OUTPUT); Serial.begin(9600); } voidloop() { // put your main code here, to run repeatedly:clockwise(rank); } voidclockwise(intSpeed) { analogWrite(motorIn1,0); analogWrite(motorIn2,Speed); }