Detect two buttons with only one analog input

So i have an idea for reading two buttons with only one analog input pin by using different resistors, but I don't know how to put it together. Currently i have it set up like this:
circuit (1)

But I cant read different inputs.

see comments, as I can't upload two images at the same time

Would it work better if I set up like this, or would that break intirely?
circuit (2)

The code i'm using currently is a simple one, as it's only for testing:

int buttons = A1;
// One button has a resistor of 220 ohm, the other has 10 kOhm
// This should enable the detection of two seperate buttons with only one analog input pin.
int button01State;

void setup() {
  Serial.begin(9600);
  Serial.println("RESET");  
}

void loop() {
  button01State = analogRead(buttons[0]);
  if(button01State > 0) {
    Serial.println(button01State);
  }
}

It only prints close to 1023 when any button is pressed, no difference between the two.

Would the other setup fix this?

Your second diagram is better but still puts 5V on the input when either or both of the switches are pressed and leaves the input floating if neither is pressed.

Add a 10k resistor from A1 to Ground. That will act a part of a voltage divider.
When no button is pressed: 0V
When the top button is pressed: 2.5V (10k/(10K+10K))
When the bottom button is pressed: 4.89V (10K/10.220k)

Hi,
try this way:

if both switches are open, it will read +- 503,
If the top switch is closed, it will read +- 240,
If the switch below is closed, it will read +- 340 and
if both are closed, it will read 0.

ed4c191cf0f65539dfb99217aa6cbb2aee593128

circuit (4)
So this should work?
I tried and don't really get anything. I'll continue looking if i did anything wrong

Yes. You should get three different values (maybe even 4 if you press both).

Yes, I got it to work! thank you!

time to rewire my whole thing, as I have that circuit 5 times

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.