Netduino 101 : potentiometer example

My helpful picture

potentiometer example takes analog input and light up leds accounting to the input 1023 divide by 5;

namespace potentiometer_netduino
{
	public class Program
	{
		public static void Main()
		{
			var voltagePort = new AnalogInput(Pins.GPIO_PIN_A1);
			var lowPort = new OutputPort(Pins.GPIO_PIN_A0, false);
			var highPort = new OutputPort(Pins.GPIO_PIN_A2, true);

			OutputPort led1 = new OutputPort(Pins.GPIO_PIN_D1, false);
			OutputPort led2 = new OutputPort(Pins.GPIO_PIN_D2, false);
			OutputPort led3 = new OutputPort(Pins.GPIO_PIN_D3, false);
			OutputPort led4 = new OutputPort(Pins.GPIO_PIN_D4, false);
			OutputPort led5 = new OutputPort(Pins.GPIO_PIN_D5, false);

			AnalogInput socket = new AnalogInput(Pins.GPIO_PIN_A5);

			int INPUT=;
			while (true)
			{
				INPUT = socket.Read();
				if (INPUT > 100 && INPUT <= 200) {
					led1.Write(true); led2.Write(false);
					led3.Write(false); led4.Write(false);
					led5.Write(false);
				}
				else if (INPUT > 200 && INPUT <= 400) {
					led1.Write(true); led2.Write(true);
					led3.Write(false); led4.Write(false);
					led5.Write(false);
				}

				else if (INPUT > 400 && INPUT <= 600) {
					led1.Write(true); led2.Write(true);
					led3.Write(true); led4.Write(false);
					led5.Write(false);
				}
				else if (INPUT > 600 && INPUT <= 800) {
					led1.Write(true); led2.Write(true);
					led3.Write(true); led4.Write(true);
					led5.Write(false);
				}
				else if (INPUT > 800 && INPUT <= 1000) {
					led1.Write(true); led2.Write(true);
					led3.Write(true); led4.Write(true);
					led5.Write(true);
				}
				else if (INPUT < 100) {
					led1.Write(false); led2.Write(false);
					led3.Write(false); led4.Write(false);
					led5.Write(false);
				}
				Debug.Print(INPUT + " ");
			}
		}
	}
} 
comments powered by Disqus