Ardunio Basic Connections


Inputs

Switch

The Setup

	pinMode(pin#, INPUT); // define which pin you are going to use for the reed switch
	digitalWrite(pin#, HIGH); // turn on the internal pull-up resistor for this pin
	

Now wire the reed switch between the pin defined and a arduino ground pin.

Reading the Input

	digitalRead(pin#);
	

When you do your digitalRead(pin#); statements, a LOW returned value means reed switch is on and a HIGH means it's off.

Potentiometer

The Setup

	pinMode(pin#, INPUT); // define which pin you are going to use for the potentiometer
	

A pot with it's end terminals wired to ground and +5vdc and it's wiper wired to a analog input pin requires no other pull-up resistor, internal or external. The pot itself will always present a proper electrical signal to the input pin.

	analogRead(pin#); // read the analog value for this pin