Interaction between GPIO's - erratic?


#1

I just made an enclosure with all 20 GPIO's used. For pots, LEDs and switches.
I connect pots to all analog INs, except PB0 and PB1, to which I connect switches.

When I connected the help patch analog.axh I discovered that turning one knob changes more than one displays (disp/chart p).
I get this behaviour:
- When I turn pot PA7, the displays of PA7 and PB0 and PB1 move.
- When I switch PB0, the displays of PB0 and PB1 move.

Is this erratic or expected behaviour?


#2

Unconnected or floating (open switch...) analog inputs follow previous inputs (in analog scanning order), because the analog to digital convertor keeps some charge.
Use a pull-up or pull-down resistor for switch inputs, and read them with gpio/in/digital - you can actually soft-configure the presence of a pull-up or pull-down resistor there.


#3

Thanks for your swift reply. I connected according to your diagram here.
Check if I understand you correctly: Is a resistor necessery for proper functioning (as I always connect the B0 and B1 to a gpio/in/digital and never to an analog gpio). And if so does the resistor go between switch and VDD or between switch and GPIO? I'm unaware of what pullup or down resistors do.


#4

A pull-down resistor is one to GND, a pull-up resistor is one to VDD. They define logic levels in case nothing else does.
You do not need to connect a real resistor, use gpio/in/digital with the option "pull-down" selected.
You'll observe influence when reading PB0 and PB1 in analog mode while the switch is open, that is expected behavior, but there is no influence when reading the switches digitally.


#5

That is perfectly clear now, thankyou! :smile:


#6

Woa sweet! That's like exactly what I was looking for today!

I ran into the exact same problem as op and thought to myself "ah crap I need to add a bunch of resistors now, I wish someone could just do this on the software side....bam! Wish granted again, 30steps closer to finishing my synth!