Go Down

Topic: grounding and potentiometers? (Read 1 time) previous topic - next topic


hi there,
i am having problems with hooking up a simple 10k potentiometer to the arduino. if i touch the potentiometer i get very stable values but as soon as i take my hand of it it starts to become unstable. i am suspecting this is due to improper grounding. would this effect stop if i would screw the potentiometer into a metal box? (and if i would use proper connectors and wires to the arudino)?

here my script:
Code: [Select]

#include <MIDI.h>
#define LED 13    // LED pin on Arduino board

void setup() {
  pinMode(LED, OUTPUT);
  MIDI.begin(1);            // Launch MIDI with default options

void loop() {
  int inFader         = 0;
  static int prevVal  = 0;
  inFader    = (inFader + analogRead(0));
  inFader    = (inFader + analogRead(0));
  inFader    = (inFader + analogRead(0));
  inFader    = (inFader + analogRead(0));
  inFader    = (int) (inFader * 0.25) * 0.125;
  if (inFader != prevVal) {
     MIDI.sendControlChange(10, inFader,1); //cc, val, ch; 0 = ch16!
     prevVal = inFader;


I'm not sure why you're reading the input multiple times then "averaging" the values (not sure why you're averaging the four measurements, then taking 1/8 of that measurement, either) - unless you were trying to combat what you are seeing.

It may be that you need better grounding (or shielding, actually) - but I really suspect that it may be those funky paperclips inducing/picking up noise, adding parasitic capacitance, extra resistance, who knows what...

I would first try removing those from the leads, stripping and re-tinning the ends of the leads well to be able to insert them directly into the headers (or solder on short lengths of solid -copper- wire for the ends).

Good luck.
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131