close
解壓檔案
網站架設 Arduino ESP32 若何 鍵盤控制 伺服馬

網站架設 Arduino ESP32 若何 鍵盤控制 伺服馬

先到打開伺服esp32網址(上方網址)
網站架設 Arduino ESP32 若何 鍵盤控制 伺服馬
網站架設 Arduino ESP32 若何 鍵盤控制 伺服馬

網站架設 Arduino ESP32 若何 鍵盤控制 伺服馬

 

寫入時假如泛起了下方狀況
網站架設 Arduino ESP32 若何 鍵盤控制 伺服馬

 

網站架設 Arduino ESP32 若何 鍵盤控制 伺服馬

文章出處:網頁設計,網站架設 ,網路行銷,網頁優化,SEO - NetYea 網頁設計

影片



伺服馬達接線圖
網站架設 Arduino ESP32 若何 鍵盤控制 伺服馬網站架設 Arduino ESP32 若何 鍵盤控制 伺服馬

黃線  GPIO27  紅線  5V  黑線  GND
ESP32 電力只能鞭策一個馬達,假如要鞭策兩個馬達就要外接電源了

程式碼

  1. #include <Servo.h>
  2. Servo myservo;  // 創設伺服馬達控制
  3.  
  4. // 伺服馬達的毗連 GPIO
  5. static const int servoPin = 27;
  6. int pos = 0;
  7. void setup() {
  8.   // put your setup code here, to run once:
  9.   myservo.attach(servoPin);  // 將伺服馬達毗鄰的GPIO pin毗鄰伺服物件
  10.   Serial.begin(115200);//序列阜連線速率
  11. }
  12.  
  13. void loop() {
  14.   // put your main code here, to run repeatedly:
  15.   if(Serial.available()){                 //
  16.     int num = Serial.parseInt();     // case 前置 num(數字鍵)
  17.    
  18.     switch(num) {                            //   
  19.    
  20.       case 1 :   //1~9
  21.         for(pos = 0; pos < 180; pos += 1) // 一度一度由 0 度旋轉到 180 度
  22.         myservo.write(pos);
  23.         delay(200);
  24.         break;
  25.       
  26.       case 2 : // 1~9
  27.         for(pos = 180; pos>=1; pos-=1) // 一度一度由 180 度扭轉到 0 度
  28.         myservo.write(pos);
  29.         delay(200);
  30.         break;
  31.     }
  32.   }
  33. }
複製代碼

 

開啟監控視窗
輸入 1 或 2 ,步進馬達就會轉180度
網站架設 Arduino ESP32 若何 鍵盤控制 伺服馬

 

網站架設 Arduino ESP32 若何 鍵盤控制 伺服馬

解決方式



注意!

 

找到arduino 資料夾 libraries 貼上 ServoESP32-master 資料夾 即可
網站架設 Arduino ESP32 若何 鍵盤控制 伺服馬

 

arrow
arrow
    文章標籤
    網站架設
    全站熱搜
    創作者介紹
    創作者 hallk6k22ej 的頭像
    hallk6k22ej

    新竹網站架設

    hallk6k22ej 發表在 痞客邦 留言(0) 人氣()