數位輸出時成效
INA
|
INB
|
結果
|
HIGH
|
LOW
|
正轉
|
LOW
|
HIGH
|
反轉
|
LOW
|
LOW
|
休止
|
HIGH
|
HIGH
|
截止
|
類比輸出要注意的地方則是,由於電壓太低通常沒法啟動,所以先把output加到255,再從80逐漸上升。
INA
|
INB
|
效果
|
80~255
|
LOW
|
漸漸增加正轉
|
LOW
|
80~255
|
漸漸增加反轉
|
將INB、INA分別接在GPIO26及GPIO27上,INB與INA代表正反轉
Arduino EPS32 DEVKIT V1 腳位
- int INA = 26;
- int INB = 27;
-
- void setup()
- {
- Serial.begin(9600);
- pinMode(INA,OUTPUT);
- pinMode(INB,OUTPUT);
- //digital output test
- Serial.println("INA=LOW,INB=HIGH");
- digitalWrite(INA,LOW);
- digitalWrite(INB,HIGH);
- delay(3000);
- Serial.println("INA=HIGH,INB=LOW");
- digitalWrite(INA,HIGH);
- digitalWrite(INB,LOW);
- delay(3000);
- Serial.println("INA=LOW,INB=LOW");
- digitalWrite(INA,LOW);
- digitalWrite(INB,LOW);
- delay(3000);
- Serial.println("INA=HIGH,INB=HIGH");
- digitalWrite(INA,HIGH);
- digitalWrite(INB,HIGH);
- delay(3000);
- //analog output(PWM) test
- ledcSetup(0, 5000, 8);
- ledcSetup(1, 5000, 8);
- ledcAttachPin(INA, 0);
- ledcAttachPin(INB, 1);
- //prepare forward
- Serial.println("INA=i++,INB=LOW");
- ledcWrite(1, 0);
- ledcWrite(0, 255);//避免電流太低沒法啟動
- delay(300);
- for (int i=80;i<=255;i++)
- {
- ledcWrite(0, i);
- ledcWrite(1, 0);
- Serial.println(i);
- delay(100);
- }
- ledcWrite(0, 0);
- ledcWrite(1, 0);
- delay(3000);
- //prepare reverse
- Serial.println("INA=LOW,INB=i++");
- ledcWrite(0, 0);
- ledcWrite(1, 255);//避免電流太低沒法啟動
- delay(300);
- for (int i=80;i<=255;i++)
- {
- ledcWrite(1, i);
- ledcWrite(0, 0);
- Serial.println(i);
- delay(100);
- }
- ledcWrite(0, 0);
- ledcWrite(1, 0);
- delay(3000);
- }
-
- void loop()
- {
-
-
- }
複製代碼
影片
文章出處:網頁設計,網站架設 ,網路行銷,網頁優化,SEO - NetYea 網頁設計
使用L9110 Fan Motor,可以用PWM節制轉速,不會像DC馬達一路動吃掉電流,致使當機。
來自:
文章定位: