Benoit Moreau
/
Servo_Temp
Servo that moves based on temperature readings from a thermistor
Diff: main.cpp
- Revision:
- 2:319ee9815aba
- Parent:
- 1:563cf31920da
- Child:
- 3:1dd8980f5f07
--- a/main.cpp Wed Nov 13 16:18:07 2019 +0000 +++ b/main.cpp Wed Nov 13 17:02:21 2019 +0000 @@ -11,10 +11,12 @@ for(;;){ //for-loop that will allow the program to run through multiple iterations float tempurature; float y;//float value that stores the duty-cyle calculated on line 15 + int bite; tempurature=readtempurature(&temp); //calls the temperature function and stores its return value y = (((0.3*tempurature) + 3)/100); //formula that converts the temperature measured by the thermistor into an equivalent duty-cycle, in order for the servo to display an accurate 1:1 scale, change the constant from 0.3 to 0.05 servo.period(0.02); // sets the period of the servo PWM to 20 ms as specifed in lesson 7 servo.write(y); //writes the calculated duty-cycle to the servo + bite=((28.333333333333*y)-85); printf("The tempurature is: %f\n",tempurature);//prints the temperature in celcius to the serial terminal wait(0.5); //waits for half a second before running the next iteration }