adding setHeater and test ok

main
Gerardo Marx 2 days ago
parent ef4e54d443
commit 10c438cfc1

@ -13,7 +13,7 @@ int T1Val;
int T2Val; int T2Val;
const int nAvg = 10; // samples per reading const int nAvg = 10; // samples per reading
const long BAUD = 115200; // Freq serial comm const long BAUD = 115200; // Freq serial comm
const float factor = 3.3/1024*100; // 3.3V/1024 const float factor = 3.3/1024*100; // 3.3V/1024*100
// functions // functions
@ -25,11 +25,23 @@ float readDeg(int channel) {
return acc/nAvg; return acc/nAvg;
} }
void setHeater(int pin, float value) {
// clamp the input value
if(value<0) value = 0;
if(value>100) value = 100;
//convert to pwm 0 - 255
int pwm = (int)(value*255.0/100.0+0.5);
analogWrite(pin, pwm);
analogWrite(LED, pwm);
}
void setup() { void setup() {
// put your setup code here, to run once: // put your setup code here, to run once:
pinMode(Q1, OUTPUT);
pinMode(Q2, OUTPUT);
pinMode(LED, OUTPUT); pinMode(LED, OUTPUT);
setHeater(Q1,40);
analogReference(EXTERNAL); analogReference(EXTERNAL);
Serial.begin(BAUD); Serial.begin(BAUD);
delay(100); delay(100);
Loading…
Cancel
Save