Rotary switch pot only outputting 0

Between CCW and W I'm getting a range between 0.2 and 0.8 ohms. Between CCW and CW i'm not getting any readings. I'm not getting any readings for W and CW either.

1 Like

Than you have some open circuit(s) in your solder connections.
You should not have 0R2 ohms and 0R8, you should have multiples of 10K.

What is the colour code on your resistors?
What value of resistance do you get when you measure one of them with your DMM?

Can you post an image(s) of the component side of the PCB?

Thanks.. Tom.. :smiley: :+1: :coffee:

1 Like

@TomGeorge, so I measured each pair of resistors (color code is brown black red gray) and consistently got 10 ohms when I set the DMM to 20k ohms.
I think the issue is completely with the CW header. I tried measuring between the pin attached to the CW pin (right above the word Rotary in the image above) and both the W and CCW pins and still not getting any readings.
Here are some more images of my project:



Your switch has detents to hold it in position when it is set to a given resistor. Are you sure you are leaving the switch set in a detent position? Your descriptions tell me you are not.

@Paul_KD7HB, yes I know, that is why I bought it :slight_smile: . I am not sure it is set to a specific position. This knob kind of rotates going past the final position it seems. In some cases, it is as if the knob isn't rotating the switch at all.

But, is the knob rotating the shaft of the switch? Does the knob use set screws?

1 Like

@Paul_KD7HB

This is what I'd like to know too.
It does not use set screws.
I might just wait for this to become available Black Knob - 15x19mm - COM-09998 - SparkFun Electronics. Set it with a screw and run a few resistance tests.

Hello icefreezer7

Post a wiring diagramm of your project.

Good grief! Take the knob off and use pliers to turn the switch shaft!

1 Like

Post a clear picture if the bottom of your pcb. So that wecan gave a look at tge solder joints...

You mean 10k on the 20Kohm scale? As expected?

You could measure lots of other things as well -- whether all the resistors are connected together in series, if and where a break in the circuit is between them, whether they connect to CW and CCW, and whether W connected to the wiper of the physical switch.

Brown black orange silver???

@DaveX yes exactly. They are 10K ohm resistors after all.
@build_1971 yes, that looks accurate or my eyes are becoming color blind :melting_face:
@Paul_KD7HB thank you for your input. I can confirm turning the shaft works with pliers.

So I switched the leads on my DMM and now i'm getting a reading between CW and (CCW and W). But when I connect it to a breadboard, I am now getting weird output from the arduino. It is outputting decreasing values from 1024 down to 0 then increasing up to 1024 again. I haven't changed my sketch or circuit.

1 Like

What circuit?

I don't see a schematic or pics of a circuit, as per:

You could check your breadboard connections with your DMM as well--when you hook it up to power and gnd, each resistor should be at a different voltage from ground, and that voltage at the wiper should match the voltage at A2.

Are all the voltages as expected?

@DaveX
Sorry if I caused confusion. By circuit, I mean the circuit I described in my first post where CCW is connected to 5V, W to A2 and CW to gnd. I did not think a schematic would be needed in this case.
Here is a sampling of the outputs from my arduino nano, please let me know if it looks normal given my sketch 1000 posts above:

17:15:35.132 -> 1023
17:15:35.227 -> 1023
17:15:35.324 -> 1023
17:15:35.421 -> 1023
17:15:35.518 -> 1023
17:15:35.646 -> 1023
17:15:35.741 -> 1023
17:15:35.837 -> 1023
17:15:35.934 -> 1023
17:15:36.030 -> 1023
17:15:36.127 -> 1023
17:15:36.223 -> 1023
17:15:36.320 -> 1010
17:15:36.448 -> 960
17:15:36.543 -> 904
17:15:36.640 -> 816
17:15:36.737 -> 739
17:15:36.833 -> 642
17:15:36.929 -> 550
17:15:37.025 -> 446
17:15:37.153 -> 333
17:15:37.250 -> 171
17:15:37.347 -> 0
17:15:37.444 -> 0
17:15:37.540 -> 0
17:15:37.637 -> 0
17:15:37.734 -> 0
17:15:37.831 -> 0
17:15:37.928 -> 0
17:15:38.024 -> 0
17:15:38.153 -> 0
17:15:38.249 -> 65
17:15:38.345 -> 97
17:15:38.441 -> 115
17:15:38.538 -> 110
17:15:38.635 -> 96
17:15:38.731 -> 0
17:15:38.828 -> 0
17:15:38.956 -> 0
17:15:39.052 -> 28
17:15:39.149 -> 94
17:15:39.246 -> 150
17:15:39.342 -> 237
17:15:39.439 -> 314
17:15:39.535 -> 413
17:15:39.630 -> 532
17:15:39.759 -> 651
17:15:39.856 -> 801
17:15:39.953 -> 904
17:15:40.049 -> 966
17:15:40.144 -> 1023
17:15:40.241 -> 1023
17:15:40.337 -> 1023
17:15:40.434 -> 1023
17:15:40.562 -> 1023
17:15:40.659 -> 859

This is a good thing. The ADC (analog to digital converter) is 10-bit resolution on a Nano.
That means 2^10.
2^10 = 1024 digital reference points between 0-5 volts (that's the analog part) or values ranging from 0-1023.

Now if you wanted to map this value to a PWM pin to output to some device such as fading an LED, you would need to map the raw ADC readings to allow the 8-bit PWM channels to use the full range of the pot.

This is demonstrated in the IDE example sketch File > Examples > 03. Analog > Calibration:

/*
  Calibration

  Demonstrates one technique for calibrating sensor input. The sensor readings
  during the first five seconds of the sketch execution define the minimum and
  maximum of expected values attached to the sensor pin.

  The sensor minimum and maximum initial values may seem backwards. Initially,
  you set the minimum high and listen for anything lower, saving it as the new
  minimum. Likewise, you set the maximum low and listen for anything higher as
  the new maximum.

  The circuit:
  - analog sensor (potentiometer will do) attached to analog input 0
  - LED attached from digital pin 9 to ground through 220 ohm resistor

  created 29 Oct 2008
  by David A Mellis
  modified 30 Aug 2011
  by Tom Igoe
  modified 07 Apr 2017
  by Zachary J. Fields

  This example code is in the public domain.

  https://www.arduino.cc/en/Tutorial/BuiltInExamples/Calibration
*/

// These constants won't change:
const int sensorPin = A0;  // pin that the sensor is attached to
const int ledPin = 9;      // pin that the LED is attached to

// variables:
int sensorValue = 0;   // the sensor value
int sensorMin = 1023;  // minimum sensor value
int sensorMax = 0;     // maximum sensor value


void setup() {
  // turn on LED to signal the start of the calibration period:
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);

  // calibrate during the first five seconds
  while (millis() < 5000) {
    sensorValue = analogRead(sensorPin);

    // record the maximum sensor value
    if (sensorValue > sensorMax) {
      sensorMax = sensorValue;
    }

    // record the minimum sensor value
    if (sensorValue < sensorMin) {
      sensorMin = sensorValue;
    }
  }

  // signal the end of the calibration period
  digitalWrite(13, LOW);
}

void loop() {
  // read the sensor:
  sensorValue = analogRead(sensorPin);

  // in case the sensor value is outside the range seen during calibration
  sensorValue = constrain(sensorValue, sensorMin, sensorMax);

  // apply the calibration to the sensor reading
  sensorValue = map(sensorValue, sensorMin, sensorMax, 0, 255);

  // fade the LED using the calibrated value:
  analogWrite(ledPin, sensorValue);
}

@hallowed31 right that makes sense. But I expected a single value output from the nano. I guess I misunderstood how this component works, but I assumed the wiper (W) pin on it should only be giving a single resistance. I needed discrete values output when the switch changes its position.

Ok, so that's where your code comes in. What do you need? I'd say that the finite state machine is what you'd like to build, ideally (it's for a sim, which is a game, right?).

You know what I mean by that?

1 Like

Did you turn the knob from one end to the other in 1sec? Or did you not touch the knob and it changed full scale?

Filtering your setup through your posts, and the forum to out here, it is difficult to tell what would be normal.

1 Like

" brown black red gray"
If you read the color bands backward, that would be 82 Ohms,1%.
Are your resistors 4 band or 5?

Resistor color codes