user20169: for the purpose of learning, I'm trying to have a kind of digital/binary input where I'm using 3 buttons but only 2 input pins.
I thought of
01 = Button 1
10 = Button 2
11 = Button 3

My first attempt was like this:

I left the resistors out right now. The problem here is of course, that it doesn't matter what button I press, both LEDs are lighting up.
I used 2 Diodes in my second attempt:

This time, S1 and S2 work as expected, but S3 brings only one LED up.
Now I was wondering how I can wire things up correctly, using as little components as possible and having in mind, that I'm going to use an Arduino instead of the LEDs.
Thank you for any help!

user4143: The logic of your second attempt is perfectly correct.
If you put resistors in series with the LEDs you may get more joy out of it. Having two LEDs in parallel without resistors often results in one LED lighting and the other not.


20169: <p>for the purpose of learning, I'm trying to have a kind of digital/binary input where I'm using 3 buttons but only 2 input pins.</p>

<p>I thought of</p>

<pre><code>01 = Button 1
10 = Button 2
11 = Button 3
</code></pre>

<p>My <strong>first attempt</strong> was like this:<br>
<a href="https://i.stack.imgur.com/Z9bpj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z9bpj.png" alt="first attempt"></a><br>
I left the resistors out right now. The problem here is of course, that it doesn't matter what button I press, both LEDs are lighting up.</p>

<p>I used 2 Diodes in my <strong>second attempt</strong>:
<a href="https://i.stack.imgur.com/Eu42f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Eu42f.png" alt="second attempt"></a><br>
This time, S1 and S2 work as expected, but S3 brings only one LED up.</p>

<p>Now I was wondering how I can wire things up correctly, using as little components as possible and having in mind, that I'm going to use an Arduino instead of the LEDs.</p>

<p>Thank you for any help!</p>
 4143: <p>The logic of your second attempt is perfectly correct.</p>

<p>If you put resistors in series with the LEDs you may get more joy out of it. Having two LEDs in parallel without resistors often results in one LED lighting and the other not.</p>

<p><a href="https://i.stack.imgur.com/eNI7M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eNI7M.png" alt="enter image description here"></a></p>
