Main Site Documentation

Reading Six Potentiometer at the same time? (Panda)


I’m working on a project that need to read values from six 10K potentiometer sliders,
that connected to analog pins, An0 - An5 (See images for schematic.)

Everything seem to work well. But one thing that I am not happy with it is that
whenever I slide one of the sliders up and down (I set the scale for all the sliders between 0-255).
All the other sliders seem to increase/decrease the value as well.(see the debug result on the image.)
The values seem to be in the ~10% range of the one that is used.

This is probably a noise among the analog pins (An0 - An5)???
My question is that if there are any way to get ride of these noise?
And how, any suggestion?

Here si the code that I use to measure the values of the sliders:

using System;
using System.Threading;

using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

using GHIElectronics.NETMF.FEZ;

using GHIElectronics.NETMF.Hardware;

namespace FEZ_Panda_Application1
    public class Program
        const int avgCount = 6;

        // Slider Potentiometers
        //Color, Saturation, Bright, Transparent, Width, Fade;
        static AnalogIn colorSlider       = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An0);
        static AnalogIn saturateSlider    = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An1);
        static AnalogIn brightSlider      = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An2);
        static AnalogIn transparentSlider = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An3);
        static AnalogIn widthSlider       = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An4);
        static AnalogIn fadeSlider        = new AnalogIn((AnalogIn.Pin)FEZ_Pin.AnalogIn.An5);

        static int colorValue, saturationValue, brightValue, transparentValue, widthValue, fadeValue;

        static int[] colorAvg       = new int[avgCount];
        static int[] saturationAvg  = new int[avgCount];
        static int[] brightAvg      = new int[avgCount];
        static int[] transparentAvg = new int[avgCount];
        static int[] widthAvg       = new int[avgCount];
        static int[] fadeAvg        = new int[avgCount];

        static bool buttonState;

        static InputPort Button = new InputPort((Cpu.Pin)FEZ_Pin.Digital.Di7, true,
        public static void Main()
            int index = 0;
            colorSlider.SetLinearScale(0, 256);
            saturateSlider.SetLinearScale(0, 256);
            brightSlider.SetLinearScale(0, 256);
            transparentSlider.SetLinearScale(0, 256);
            widthSlider.SetLinearScale(0, 256);
            fadeSlider.SetLinearScale(0, 256);

            //reset sliders average
            for (int i = 0; i < avgCount; i++)
                colorAvg[i] = 0;
                saturationAvg[i] = 0;
                brightAvg[i] = 0;
                transparentAvg[i] = 0;
                widthAvg[i] = 0;
                fadeAvg[i] = 0;

            while (true)
                //Read button
                buttonState = Button.Read();

                //calc average value
                colorAvg[index]       = colorSlider.Read();
                saturationAvg[index]  = saturateSlider.Read();
                brightAvg[index]      = brightSlider.Read();
                transparentAvg[index] = transparentSlider.Read();
                widthAvg[index]       = widthSlider.Read();
                fadeAvg[index]        = fadeSlider.Read();

                // increment index, if index > array size reset to zero
                if (index >= avgCount)
                    index = 0;

                // calc sliders average value


                //Display the sliders' value
                Debug.Print("Sliders: " +
                    (colorValue).ToString() + "\t" + (saturationValue).ToString() + "\t" +
                    (brightValue).ToString() + "\t" + (transparentValue).ToString() + "\t" +
                    (widthValue).ToString() + "\t" + (fadeValue).ToString());

                Debug.Print("Button: " + buttonState.ToString());

        public static void slidersAverage()
            colorValue = 0;
            saturationValue = 0;
            brightValue = 0;
            transparentValue = 0;
            widthValue = 0;
            fadeValue = 0;

            for (int i = 0; i < avgCount; i++)
                colorValue += colorAvg[i];
                saturationValue += saturationAvg[i];
                brightValue += brightAvg[i];
                transparentValue += transparentAvg[i];
                widthValue += widthAvg[i];
                fadeValue += fadeAvg[i];

            colorValue       /= avgCount;
            saturationValue  /= avgCount;
            brightValue      /= avgCount;
            transparentValue /= avgCount;
            widthValue       /= avgCount;
            fadeValue        /= avgCount;


I wonder if using 1K pull down resistors on analog pings will help. Try that.

Also, check this:


Looks like when the slider is low you’re sending 5V into the analogin. What happens when you bias the pot array with 3v3?


Or if you really want to use 5v connect aref pin to 5v as well?



That’s solve the problem! ;D

Thanks to you too, Architect.


Yes, you can’t exceed 3.3V on analog inputs


cool. glad it’s working Sam.

@ architect – the AREF pin from arduino pinout is NC on panda. AREF is hard wired to 3v3 at the chip. I’ve briefly considered doing surgery to “fix” that…


Did you think of why GHI didn’t leave vref on the pins, so you can connect it to 5V? :slight_smile:

It is because 5V on vref will damage the processor and this is why GHI didn’t connect it :wink:


This project is an old project that I am replacing the Arduino with Panda.
And the connections was on 5V.
I totally forget about this 3.3V, as it was mentioned in the eBook.


[quote]5V on vref will damage the processor[/quote] ouch! :o

Just read chapter 27 section 5 of the user manual.

Good to know! Thanks


I forgot this too lately. Luckily the GHI/tinyclr boards are so robust 8)


@ Gus, I was contemplating “surgery” to allow me to supply <3v3 to the chip’s vref. Trying to get better ADC resolution at low voltage levels.