Arduino analogue pin problem

Status
Not open for further replies.

boylesg

Advanced Member level 4
Joined
Jul 15, 2012
Messages
1,023
Helped
5
Reputation
10
Reaction score
6
Trophy points
1,318
Location
Epping, Victoria, Australia
Visit site
Activity points
11,697
I am having trouble with the following circuit.

Q1, Q2 and Q3 have their emitters connected to analogue pins 0, 1 and 2 on my arduino and I am monitoring the voltage levels.

Imagine that S1 and S2 are keys on an electronic keyboard. What I am trying to do is to ultimately map 24 keys (or what ever) to 24 unique combinations of HIGHs and LOWs on the 6 analogue pins.

What I was expecting to happen was that, when I close S1, analogue pins 0 and 2 would go HIGH but analogue pin 1 would remain LOW.

But it is not working as I envisaged.

I soon discovered that the voltage level of floating analogue pins oscillate fairly unpredictably around roughly 2V.

And when I do close S1, all 3 analogue pins go to HIGH (4V or there abouts).

Any suggestions on how I can get this to work as expected.
 

Actually I figured out. I need a high value resistor, e.g. 100k, from each arduino analogue pin to GND to tie the analogue pins down to a known reference value for when the transistor switches on and its emitter goes HIGH.

And I need diodes on both the leads leaving S1 to the transistor bases and diodes on both leads leaving S2 to the transistor bases.

If I do that then the serial output from the arduino behaves exactly as I expect.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…