Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float PMT_raw {0.0f};
- float PMT_V {0.0f};
- float PMT_mV {0.0f};
- const uint8_t Vcont=15; //control voltage ?硫?/// gain provided to pin 15 of esp32
- float Gain {0.0f};
- //pwm setting area
- const int freq = 5000;
- const uint8_t pwmChannel = 0;
- const uint8_t pwmResolution = 8; // 8-bit resolution (0-255)
- void setup()
- {
- Serial.begin(9600);
- ledcSetup(pwmChannel, 5000, pwmResolution); // 5 kHz frequency
- // Attach the PWM channel to the GPIO pin
- ledcAttachPin(15, pwmChannel);
- Gain=255*0.16f; //Gain 夜??쑣????쀪텢 ???쑣?룹?釉?/?쑣??
- ledcWrite(pwmChannel,Gain );
- }
- void loop() {
- //-----------PMT夜???꾪???????怨쀬쟿------------
- PMT_raw=analogRead(32);
- PMT_V=PMT_raw/4095*3.3f;
- PMT_mV=PMT_V*1000.0f;
- Serial.println(PMT_mV);
- }
Advertisement
Add Comment
Please, Sign In to add comment