Servo that turns towards heat source with temperature reading display.

Dependencies:   mbed

Committer:
bmichael21
Date:
Sun Jan 13 01:26:23 2019 +0000
Revision:
3:6d27738a83dc
Parent:
2:24a919513911
Child:
6:dd0950b071e9
Child:
7:01f260a01953
fill tempSnsr files

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bmichael21 2:24a919513911 1 #include "tempSnsr.h"
bmichael21 2:24a919513911 2
bmichael21 3:6d27738a83dc 3 AnalogIn tempSnsr1(p16);
bmichael21 3:6d27738a83dc 4 AnalogIn tempSnsr2(p17);
bmichael21 3:6d27738a83dc 5
bmichael21 3:6d27738a83dc 6 float highTemp(){
bmichael21 3:6d27738a83dc 7 float temp1 = avgTemp1(), temp2 = avgTemp2();
bmichael21 3:6d27738a83dc 8 if(temp1 > temp2)
bmichael21 3:6d27738a83dc 9 return temp1; //temp1 and temp2 are already converted to farenheit measurements
bmichael21 3:6d27738a83dc 10 else
bmichael21 3:6d27738a83dc 11 return temp2;
bmichael21 3:6d27738a83dc 12 }
bmichael21 3:6d27738a83dc 13
bmichael21 3:6d27738a83dc 14 float avgTemp1(){
bmichael21 3:6d27738a83dc 15 float temp1 = 0;
bmichael21 3:6d27738a83dc 16 for(int i = 0; i < 10; i++){
bmichael21 3:6d27738a83dc 17 temp1 += tempSnsr1;
bmichael21 3:6d27738a83dc 18 }
bmichael21 3:6d27738a83dc 19 return ((temp1 / 10 * 3.3 - 0.5) * 1.8 + 32); //conversion to the actual temperature in farenheit allows for reusability of function
bmichael21 3:6d27738a83dc 20 }
bmichael21 3:6d27738a83dc 21
bmichael21 3:6d27738a83dc 22 float avgTemp2(){
bmichael21 3:6d27738a83dc 23 float temp2 = 0;
bmichael21 3:6d27738a83dc 24 for(int i = 0; i < 10; i++){
bmichael21 3:6d27738a83dc 25 temp2 += tempSnsr2;
bmichael21 3:6d27738a83dc 26 }
bmichael21 3:6d27738a83dc 27 return ((temp2 / 10 * 3.3 - 0.5) * 1.8 + 32);
bmichael21 3:6d27738a83dc 28 }
bmichael21 3:6d27738a83dc 29
bmichael21 3:6d27738a83dc 30 float tempDiff(){ //this function is simple but mainly for modularity
bmichael21 3:6d27738a83dc 31 return avgTemp1() - avgTemp2();
bmichael21 3:6d27738a83dc 32 }