Main Site Documentation

Analog Input


#1

during the study,I meet some problems.I use the following code to debug.But I havent light senor,so i use the voltage division circuit instead of it. There are two questions:

first,shall I change the name like lightSenor into batteryVoltage in the code?

second," Debug.Print(lightSensorReading.ToString());" does it mean dispaly the output to the debug window in C#? Why i dont see the results?

Thanks.

using System;
using System.Threading;
using Microsoft.SPOT;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Hardware;
 
namespace MFConsoleApplication1
{
    public class Program
    {
        public static void Main()
        {
            AnalogIn lightSensor = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An3);
            lightSensor.SetLinearScale(0, 100);
 
            int lightSensorReading = 0;
            while (true)
            {
                lightSensorReading = lightSensor.Read();
                Debug.Print(lightSensorReading.ToString());
                Thread.Sleep(500);
            }
        }
 
    }
}


#2

Please use code tags so your code is readable. I will fix your post.

Yes Debug.Print will show somehow in output window. Start reading here http://wiki.tinyclr.com/index.php?title=First_Project


#3

A couple of tips to help you get answers…

Use code tags to make your code more readable:

// like this 

Also, post in the forum related to the board you are using, and always ionclude specifics like board name, SDK version, etc.

Makes no difference what you call your object.

Yes, it should. There are user options in Visual Studio that can make it appear in the immediate window instead. It depends on what version of Visual Studio you are using (hint - tell us).