Вы находитесь на странице: 1из 2

Temperature measuring using Netduino Plus

1. Connect the left pin to 3.3v.


2. Connect 3.3v to AREF.
3. Connect the center pin to Analog0.
4. Connect the Right pin to Ground.




using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace temperature1
{
public class Program
{
public static void Main()
{
//Declare your analog input
AnalogInput a0 = new AnalogInput(Pins.GPIO_PIN_A0);

while (true)
{
// Read the temp sensor
int read = a0.Read();

//convert the reading to voltage
Double voltage = read * 3.3 / 1024;

//calculate Celsius from voltage
Double tempC = (voltage - 0.5) * 100;

//calculate Fahrenheit from Celsius
Double tempF = (tempC * 9 / 5) + 32;

//Print your results
Debug.Print("Temp in F is: " + tempF + " -- Temp in C is: " + tempC);

//sleep and do it all over again.
Thread.Sleep(1000);
}

}

}
}

Вам также может понравиться