Go Down

Topic: error using resistors to make several buttons with one pin. Lilypad mp3 (Read 392 times) previous topic - next topic

relate530

Hello!
I am trying to activate 8 buttons with two pins (4 per pin) with my lilypad mp3. I followed this tutorial, using different resistors to create the buttons  https://www.instructables.com/id/Accessing-5-buttons-through-1-Arduino-pin-Revisi/

Before running the code, I use this example to test the resistors and get the values https://www.arduino.cc/en/Tutorial/Debounce

The first pin (A0) return coherent values:

disconnected = 0
button 1: 1013
button 2: 969
button 3: 798
button 4: 889

but the second pin (A4) is not working properly.   

disconnected = 1023
button 1: 1014
button 2: 997
button 3: 983
button 4: 984

I am using the same 4 resistors for both pins. so it should return the same values for both pins.

I interchanged the connections and connect the circuit I made for pin A0 (the one that was working properly) to pinA4 but I got the same A4 values (it means it is not about the circuit but the pin reading).
I tried using pin A5 instead of A0 and get the same values than pin A4.

Any ideas why is this happening ?





vaj4088

What is your wiring?  The instructable has 5 buttons and 6 (!) resistors but you have something else.

When you write that "I am using the same 4 resistors..." do you mean identical or do you mean same value?  The resistors do have a tolerance.

You should get close to zero (NOT 1023) with no buttons pressed.  If not, then something is wired wrong or perhaps not working correctly.  More (MUCH more) information is needed to figure out what is going on.


lastchancename

Please post your <code> in code tags, and schematic as an attachment linked in-line.
Experienced responders have a nose for laziness, (they were beginners once)... Sure, there are trolls, chest-beaters, and pretenders - but the help you'll get here is about as good as it gets - if you try to help youself!.

relate530

Hello!

I am trying to create 15 buttons with three pins from my Lilypad mp3 (5 per pin), using this tutorial as a reference for electronics  https://www.instructables.com/id/How-to-access-5-buttons-through-1-Arduino-input/.

I made the connections and used this code to get the resistor values

Code: [Select]
void setup() {
  pinMode(buttonPin, INPUT);
  Serial.begin(9600);
}

void loop() {
  // read the state of the switch into a local variable:
  int reading = analogRead(buttonPin);
   Serial.println("reading   ");
   Serial.println(reading);



I got the values from the different button/resistors and then when I tried the pin 2 and 3 I noticed the values were different although the resistors (and all the circuit) were the same than pin 1.

I also tried the same circuit for all pins to make sure it wasn't a electronic or programming issue and I get the same result.

When I let the pin 1(A0) open the values goes around 0 (which is normal) but when I do the same for pin 2 and 3 (A4-A5) the values goes around 953-1023.

Any Ideas which is the error?

relate530

What is your wiring?  The instructable has 5 buttons and 6 (!) resistors but you have something else.

When you write that "I am using the same 4 resistors..." do you mean identical or do you mean same value?  The resistors do have a tolerance.

You should get close to zero (NOT 1023) with no buttons pressed.  If not, then something is wired wrong or perhaps not working correctly.  More (MUCH more) information is needed to figure out what is going on.


Thanks for your Answer!

I am using 4 resistors for 4 buttons and 1 extra resistor for pin connection as it's used in the tutorial. The resistors have different values and I am using the same circuit for each pin (5 different value resistors).

When I let the pin A0 open, I get normal values around 0 as you stated but when I connect the same circuit to pin A4 I got values around 950-1023 and when I "press" the buttons, I get different values than when I do the same connected to pin A0 (which no makes any sense) because I only changed the physical pin and the pin number in the code.

This is the code I am using just for reading the resistor value

Code: [Select]

const int Button =A0;
//const int Button =A4;
int val;

void setup () {
Serial.begin(9600);
}

void loop () {
 val=analogRead(Button);    //read ANALOG
 Serial.println(val);       
}


Thanks!

SteveMann

I have no idea what is the question.
show a circuit diagram of what you have done.

vaj4088

Do you have another Arduino to try? Have you tried A1 or A2?

Either your wiring has a problem or (less likely) your Arduino has a problem with its A4 pin.

lastchancename

I have drawers full of resistors & switches. They all work fine when they're connected properly.
 
Please respond to Replt #3
Experienced responders have a nose for laziness, (they were beginners once)... Sure, there are trolls, chest-beaters, and pretenders - but the help you'll get here is about as good as it gets - if you try to help youself!.

raymw

Just a guess, but do some of the pins have internal pull-up resistors that will need disabling?

relate530

Do you have another Arduino to try? Have you tried A1 or A2?

Either your wiring has a problem or (less likely) your Arduino has a problem with its A4 pin.
Yes, I tried with another lilypad mp3 and made the same procedure. I tried A0, A4, A5. Which I understand are the analog pins for this board (T1,T2, T3), and only works on A0.

The particular thing about this connection is the circuit works fine with pin A0 but not with A4 and I only changed the crocodile pin (from A0 to A4) and the pin number in the code above.


This are two photos of the applied circuit:

https://drive.google.com/open?id=0B_DCVGsf24LVU0dLbjg4dHhBQ1NVOWkzNERmZjNjWDR0Yy1V

https://drive.google.com/open?id=0B_DCVGsf24LVY3dMZHRSNVl3bnRHQWhtTDdKMEgwaEU1a0Qw

relate530

I have drawers full of resistors & switches. They all work fine when they're connected properly.
 
Please respond to Replt #3
Thanks. The resistors work fine with one pin, that is what makes it confuse. If it didn't work in any pin I could be sure is something about the connection.

This is the code you were asking

Code: [Select]

const int Button =A0;
//const int Button =A4;
int val;

void setup () {
Serial.begin(9600);
}

void loop () {
 val=analogRead(Button);    //read ANALOG
 Serial.println(val);       
}

lastchancename

But how is it all wired together?
A schematic - or maybe a complete well exposed photo of all your components connected together..

What you're doing isn't rocket science, so maybe you've just misunderstood something.  We'll never know.

We can't help you if you don't want to make an effort to help yourself.
Experienced responders have a nose for laziness, (they were beginners once)... Sure, there are trolls, chest-beaters, and pretenders - but the help you'll get here is about as good as it gets - if you try to help youself!.

relate530

I have no idea what is the question.
show a circuit diagram of what you have done.
I would like to know why I am getting different values when I change the pin if the circuit is the same. This is an image of the circuit I am working on  but with different resistor values
https://cdn.instructables.com/F8X/QWC3/G1BBBYQT/F8XQWC3G1BBBYQT.LARGE.jpg?auto=webp&frame=1&fit=bounds

Just a guess, but do some of the pins have internal pull-up resistors that will need disabling?
The reference code in the link active the pull up resistors at the beginning. That means is deactivated by default? How can I know if I have to deactivate the pull up resistor and how can I do that?

Thanks!

relate530

But how is it all wired together?
A schematic - or maybe a complete well exposed photo of all your components connected together..

What you're doing isn't rocket science, so maybe you've just misunderstood something.  We'll never know.

We can't help you if you don't want to make an effort to help yourself.
Sorry! I am not an expert. I don't know how to make an schematic. This are photos of all circuit.

https://drive.google.com/open?id=0B_DCVGsf24LVaFdhb1RFalRJYmJHOEthTkZneGswSTZ0M0dR

https://drive.google.com/open?id=0B_DCVGsf24LVMzdNMUxaUHZDbDJqY3pxamJoMlJnSmZPUUxn

I am connecting the bread board to GND and 3.3V from the arduino

For buttons:voltage to resistors. Resistor to button and button to pin A4 (t2) of the board
For pin reading: GND to resistor, resistor to button and pin A4

Sorry if it's more confusing :S I just replicated the scheme from the instructables tutorial

Thanks for your help!



MarkT

When someone is on the ball enough to tell you which Arduino board is involved, at least take that into
account before answering!  This is very simply a feature of the board:

The Lilypad MP3 board has I2C pullups on A4 and A5 which double as the I2C bus.  There are pcb jumpers
that can be severed with a craft knife / scapel carefully if you don't want the pullups in circuit.

You are simply seeing the effect of the on-board 4k7 resistor between A4 and 3.3V rail.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up