A Potentiometer Read/Print Loop (Ira Laefsky/P.J. Santoro)

Below find a Potentiometer Read/Debug.Print Demo
which was written by P.J. Santoro of our local Hackerspace http://www.hive76.org


using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using System.Threading;

using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;

namespace potApp
{
    public partial class Program
    {
        void ProgramStarted()
        {
            /******************************************************************************************
            Access modules defined in the designer by typing their name:                            
            
            e.g.  button
                  camera1

            Initialize event handlers here.
            e.g. button.ButtonPressed += new GTM.MSR.Button.ButtonEventHandler(button_ButtonPressed);             
            ***************************************************************************************** */

            // Do one-time tasks here
            Debug.Print("Program Started");

            while (true)
            {
                double pot_val = potentiometer.ReadPotentiometerVoltage();

                Debug.Print(pot_val.ToString());
                Thread.Sleep(1000);
            }
        }
    }
}

Is there a question here?

No question just wanted reading for a scope-like display on the T35 LCD

FYI - such offerings are better dropped into http://code.tinyclr.com/.
This way, your code is easier for others to find, read and use.

I don’t get it… Did you not paste all the code? There’s really only two lines of code there that aren’t auto generated. But, like Jimmy said if this is just reference code then it really should go to code.tinyclr.com.

Please, lets keep code.tinyclr.com clean. There is no need to flood it with something simple as this.

Thanks for the redirect on placement but getting the syntax right took us newbies from Arduino close to an hour, we will know where to place such fragments in the future.

-_Ira

generally it is not good practice to run your application within the ProgramStarted method. it should only be used for initialization. a thread should be started to do the readings.