On my arduino uno r3 I have 12 buttons on a resistor ladder connected to analog pin 0.
The buttons also have lamps on them, so I have 12 1,5v AA batteries in series to supply voltage for the lamps, and also a 9v regulator (l7809cv) to use the 18v to produce 9v for the arduino board. This has been working fine until now. When I shift between pushing two buttons (thus starting one sample on a waveshield and stopping another) a third random sample+button-light gets activated. This doesn't happen when no buttons are being pushed, and it hasn't happened before.
I then tried running it on USB-power instead (without the lamps), and it was all fine.
So I figured it must have something to do with the battery-powering.. no? So I tried measuring voltage on the output pin of the regulator, both when pushing buttons and not, and this gave me a reading around 9v, sometimes dropping just below 9v. This should be more than enough for the arduino on-board regulator, right? I mean - could this really make changes in the analogRead that I'm doing?
Here's my code: http://sorenandreasen.com/machine-nr-1-code/
EDIT: In the code, if I outcomment everything that has to do with pin 0 and 1, and instead initializes serial communication and asks it to constantly print out the analogRead-value in my loop - then it works fine. How could this be? I really don't understand how that has any effect on the readings