Skip to content

Latest commit

 

History

History
43 lines (33 loc) · 1.03 KB

OnBoardThermal.md

File metadata and controls

43 lines (33 loc) · 1.03 KB
layout title permalink
code
On Board Thermal
/OnBoardThermal.htm

On Board Thermal Sample

Learn how to use AnalogRead() to read values from the on-board thermal sensor.

Create a new project

Create a new project from the template and replace the existing code in main.cpp with the following code:

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 %}


« Return to Samples