c
c
cavedu
Search…
兩路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 程式如下
1
void setup() {
2
pinMode(5, OUTPUT);
3
pinMode(6, OUTPUT);
4
pinMode(9, OUTPUT);
5
pinMode(10, OUTPUT);
6
}
7
8
void loop() {
9
analogWrite(5,0);
10
analogWrite(6,255);
11
analogWrite(9,0);
12
analogWrite(10,255);
13
delay(2000);
14
stop();
15
16
analogWrite(5,255);
17
analogWrite(6,0);
18
analogWrite(9,255);
19
analogWrite(10,0);
20
delay(2000);
21
stop();
22
23
analogWrite(5,0);
24
analogWrite(6,255);
25
analogWrite(9,255);
26
analogWrite(10,0);
27
delay(2000);
28
stop();
29
30
analogWrite(5,255);
31
analogWrite(6,0);
32
analogWrite(9,0);
33
analogWrite(10,255);
34
delay(2000);
35
stop();
36
}
37
38
void stop() {
39
analogWrite(5,0);
40
analogWrite(6,0);
41
analogWrite(9,0);
42
analogWrite(10,0);
43
delay(2000);
44
}
45
Copied!