兩路L9110S馬達模組

專案說明

使用「科易KEYES Arduino UNO R3 開發板」連接「兩路L9110S馬達模組」, 每2秒鐘轉動馬達一次。

兩路L9110S馬達模組包含於「洞洞兩教學材料包 Education Kit 002」內。

KEYES Arduino UNO R3電路圖

  • 通用型彩色Sensor shield v5.0感測器擴充板

  • 兩路L9110S馬達模組

  • 微型N20直流減速馬達

兩路L9110S馬達模組是PWM訊號輸出, 可以接「D3、D5、D6、D9、D10」的 KEYES Arduino UNO R3訊號端上。 本範例連接到「D5←→A-IA」,「D6←→A-IB」,「D9←→B-IA」,「D10←→B-IB

Arduino 程式

5號、6號接MOTOR-A,9號、10號接接MOTOR-B。將5號、6號、9號、10號腳位的依序給不同的PWM訊號,每2秒鐘轉動馬達不同方向一次。

產生出的 Arduino 程式如下

void setup() {
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
void loop() {
analogWrite(5,0);
analogWrite(6,255);
analogWrite(9,0);
analogWrite(10,255);
delay(2000);
stop();
analogWrite(5,255);
analogWrite(6,0);
analogWrite(9,255);
analogWrite(10,0);
delay(2000);
stop();
analogWrite(5,0);
analogWrite(6,255);
analogWrite(9,255);
analogWrite(10,0);
delay(2000);
stop();
analogWrite(5,255);
analogWrite(6,0);
analogWrite(9,0);
analogWrite(10,255);
delay(2000);
stop();
}
void stop() {
analogWrite(5,0);
analogWrite(6,0);
analogWrite(9,0);
analogWrite(10,0);
delay(2000);
}