|
|
|
@ -13,7 +13,7 @@ int T1Val;
|
|
|
|
|
int T2Val;
|
|
|
|
|
const int nAvg = 10; // samples per reading
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
@ -25,11 +25,23 @@ float readDeg(int channel) {
|
|
|
|
|
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() {
|
|
|
|
|
// put your setup code here, to run once:
|
|
|
|
|
pinMode(Q1, OUTPUT);
|
|
|
|
|
pinMode(Q2, OUTPUT);
|
|
|
|
|
pinMode(LED, OUTPUT);
|
|
|
|
|
setHeater(Q1,40);
|
|
|
|
|
analogReference(EXTERNAL);
|
|
|
|
|
Serial.begin(BAUD);
|
|
|
|
|
delay(100);
|