analogRead on v3

Hello! I have a v3 and attempting to use a simple potentiometer but getting no change in analogRead from the specified pin. And even when the pin is not connected to anything the value is stuck at 0.999756. I get the same 0.999756 with pins 0, 2, 4, 13, 14, 25 and 27, but 0.0 on pins 19, 21, 22, 33 (these also don’t change when connected to the pot). Thoughts? Thank you in advance!

pinMode(26, ANALOG)
PotTest = analogRead(26)

export var PotTest
image

Hi Marty! Welcome to the forums!

I saw on the CrowdSupply documentation that only pins 14, 25, 26, 27, and 33 support analogRead() (and pin 25 isn’t broken out for easy access). Keep in mind it’s 0-3.3V range. From testing right now on two v3’s running the latest v3.16, I was only able to get analogRead to work on pin 33.

Also wanted to make sure you place PotTest = analogRead(NN) in beforeRender() so that you get constantly updating info in the watcher. It’s not a one-time binding sort of thing, you probably want to set it up to re-read continuously.

Here’s code that worked for me on my v3:

var pin = 33
pinMode(pin, ANALOG)

export var potTest

export function beforeRender(delta) {
  potTest = analogRead(pin)
}

export function render(index) {
  v = index / pixelCount < potTest  // Visual voltmeter
  hsv(0, 1, v)
}
1 Like

Thank you, Jeff! That was the ticket… and yes, in my two v3’s analogRead only seems to work on pin 33. Much appreciated!

1 Like

Hi @martyzorro,
I’m seeing the same thing, possibly stopped working on other pins in an update along the way which is not expected.

Are you good to go with the one ADC input, or do you need more?

1 Like

Thanks for checking! I’m good to go with the one input, thank you… just a pot for brightness. FYI this is for pimping out a friend’s wheelchair … we’d rather he not be on his phone when he drives. :slight_smile:
Thanks again for your help!

3 Likes