Pages: [1]   Go Down
Author Topic: grounding and potentiometers?  (Read 1396 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 1
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

#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;

* P2043262t.jpg (349.61 KB, 731x539 - viewed 35 times.)

Phoenix, Arizona USA
Online Online
Faraday Member
Karma: 40
Posts: 5600
Where's the beer?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Pages: [1]   Go Up
Jump to: