2023-01-12 08:12:39andrewsjj3

網站架設 ESP32若何利用可變電阻讀取外部電壓數值

網站架設

影片申明:


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

ESP32 腳位34 毗連到可變電阻腳位 2
ESP32 腳位VIN 毗連到可變電阻腳位 1
ESP32 腳位GND 毗連到可變電阻腳位 3
1.jpg


讀取數值為12 bits = 4096
0 - 4095

程式碼:

  1. const int potPin = 34;
  2. int val=0;
  3. void setup() {
  4.   Serial.begin(115200); //連線速度
  5.   delay(1000);
  6. }
  7.  
  8. void loop() {
  9.   // put your main code here, to run repeatedly:
  10.   val = analogRead(potPin); //讀取電壓數值
  11.   Serial.println(val); //印出電壓數值
  12.   delay(500); //延遲0.5秒
  13. }
複製代碼
網站架設

以下文章來自: