granteeric

PMT_With_ESP32/Arduino

May 22nd, 2023
1,120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. float PMT_raw {0.0f};
  2. float PMT_V {0.0f};
  3. float PMT_mV {0.0f};
  4. const uint8_t Vcont=15; //control voltage ?硫?/// gain  provided to pin 15 of esp32
  5. float Gain {0.0f};
  6.  
  7. //pwm setting area
  8. const int freq = 5000;
  9. const uint8_t pwmChannel = 0;
  10. const uint8_t pwmResolution = 8;  // 8-bit resolution (0-255)
  11.  
  12. void setup()
  13. {
  14.   Serial.begin(9600);
  15.   ledcSetup(pwmChannel, 5000, pwmResolution);  // 5 kHz frequency
  16.  
  17.   // Attach the PWM channel to the GPIO pin
  18.   ledcAttachPin(15, pwmChannel);
  19.  
  20.   Gain=255*0.16f; //Gain 夜??쑣€????쀪텢 ???쑣€?룹?釉?/?쑣€??
  21. ledcWrite(pwmChannel,Gain );
  22.  
  23. }
  24. void loop() {
  25.   //-----------PMT夜???꾪€???????怨쀬쟿------------
  26.   PMT_raw=analogRead(32);
  27.   PMT_V=PMT_raw/4095*3.3f;
  28.   PMT_mV=PMT_V*1000.0f;
  29.  
  30. Serial.println(PMT_mV);
  31.  
  32. }
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
Advertisement
Add Comment
Please, Sign In to add comment