View difference between Paste ID: NEJMEgWv and EQ8K0LE4
SHOW: | | - or go back to the newest paste.
1
float PMT_raw {0.0f};
2-
float PMT_raw;
2+
float PMT_V {0.0f};
3-
float PMT_V;
3+
float PMT_mV {0.0f};
4-
float PMT_mV;
4+
const uint8_t Vcont=15; //control voltage ?硫?/// gain  provided to pin 15 of esp32
5-
int Vcont=15; //control voltage ?硫?/// gain  provided to pin 15 of esp32
5+
float Gain {0.0f};
6-
int Gain;
6+
7
//pwm setting area
8
const int freq = 5000;
9-
const int pwmChannel = 0;
9+
const uint8_t pwmChannel = 0;
10-
const int pwmResolution = 8;  // 8-bit resolution (0-255)
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-
  Gain=255*0.16; //Gain 夜??쑣€????쀪텢 ???쑣€?룹?釉?/?쑣€??
17+
18
  ledcAttachPin(15, pwmChannel);
19
20
  Gain=255*0.16f; //Gain 夜??쑣€????쀪텢 ???쑣€?룹?釉?/?쑣€??
21
ledcWrite(pwmChannel,Gain );
22
 
23
}
24-
  PMT_V=PMT_raw/4095*3.3;
24+
25-
  PMT_mV=PMT_V*1000;
25+
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