error using resistors to make several buttons with one pin. Lilypad mp3

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.

Please post your <code> in code tags, and schematic as an attachment linked in-line.

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

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?

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.

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

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!

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

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.

I have drawers full of resistors & switches. They all work fine when they’re connected properly.

Please respond to Replt #3

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

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.

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:

lastchancename:
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

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);       
}

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.

SteveMann:
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

raymw:
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!

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.

Sorry! I am not an expert. I don't know how to make an schematic. This are photos of all circuit.

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!

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.

The value read from an analog pin that is not connected is completely undefined. Could be anywhere,
the pin is floating electrically.

However the pins are not unconnected, the Lilypad MP3 schematic clearly shows most of the analog pins are internally connected to various LEDs, pull-downs, pull-ups, whatnot.

This means you have to understand that board and its schematic before using the analog pins, many of which are not available to general use.https://cdn.sparkfun.com/datasheets/Dev/LilyPad/LilyPad-MP3-v15a.pdf

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.

Thanks MarkT! Now it makes sense.
I was looking at the schematics and understand more what you said. I am scared about the cutting, never tried that before :o . Should I scratch all the copper layer or just the tiny link between the two blocks? I made this photo to illustrate better my question.

I was also using the sketch that came for default loaded to the board (trigger), which I understand mention some things about the I2C protocol. Do I have to modify this code too in order to use some of its functions?

(I've attached the sketch, too long to quote)

Thanks again for your help!

Trigger.ino (10.6 KB)

lilypadSJ1.png

Great - good work!
This is where documenting your project really helps.
Hoping your project goes well.
Schematics should indicate pull-ups etcto help visualise ‘voltage’ biases in a circuit..
10 points to @MarkT

According to the schematic, disconnect sj1 & sj2 to disable I2C pullups on a4 a5

@relate530

TOPICS MERGED.

DO NOT cross post as it wastes peoples time and efforts to help you.

Please read link this before adding any further posts.

T.I.A.

Bob.