Resistive Contact Switches

Sorry, I'm new at this but I searched the forum but couldn't really find what I was looking for.

I am trying to program 2 resistive contact switches to control a servo (one switch will move the servo to half way, the other to full). I understand the hardware end of it, and the sweeping of the servos, but I was curious how I program for the switch? How do I program for the analog input to register the change in resistance and then map that change to a value for the servo?

I appreciate any help I could get.

The "resistive contact switch" behaves exactly like a potentiometer, with one outer leg broken off.

Connect it like this:

5V ---> switch -+-> resistor ---> Gnd
|
Pin

The resistor should be about the same size as the maximum resistance of the switch.

Use analogRead to read the value of the pin. Determine the maximum and minimum values read, and pass them as the from range, to the map function.

Pass the returned value to map again, this time with the server range (0, 180 or 0, 90 or whatever). Pass the output to the servo function to position the servo.

Okay, I'm having an issue with the switch. I have it set up like you said:

5v -> || -> 10k resistor -> gnd
|
analog pin

And I have this script as part of my current sketch I've been working on:

resistance = analogRead(resistswitch1);
resistance = map(resistance, 0, 1023, 0, 1023);

Serial.println(resistance);
delay(1000);

The values I've been getting with my finger NOT on the 2 bear wires floats around 1005-1011 and when I add my finger tip to the bear wires, it doesn't change. Shouldn't there be a more drastic drop in resistance with my finger on those wires?

What about a wet finger?

Okay, I got it working now. My issue was I was using the VCC pin on my pro mini as the 5v+ power source and for some reason it wasn't working correctly. Now I have the digital pin 13 as the 5v+ and it works perfectly.

The range you should be getting on the analog pin should be 0 of nothing is on the 2 exposed wires and for me it goes up to 15ish when I touch the wires. In case anyone is interested.