layout | title | permalink |
---|---|---|
code |
On Board Thermal |
/OnBoardThermal.htm |
Learn how to use AnalogRead() to read values from the on-board thermal sensor.
Create a new project from the template and replace the existing code in main.cpp with the following code:
{% highlight C++ %} #include "stdafx.h" #include "arduino.h"
int _tmain(int argc, _TCHAR* argv[]) { return RunArduinoSketch(); }
int tempPin = -1; // The on-board thermal sensor
void setup() { }
// the loop routine runs over and over again forever: void loop() { float temperatureInDegreesCelcius = 1.0f; // Storage for the temperature value
// reads the analog value from this pin (values range from 0-1023) temperatureInDegreesCelcius = (float) analogRead(tempPin);
Log(L"Temperature: %lf Celcius\n", temperatureInDegreesCelcius); Sleep(100); // Provides a delay for our visual pleasure } {% endhighlight %}