Introduction: How to Access 5 Buttons Through 1 Arduino Input

Picture of How to Access 5 Buttons Through 1 Arduino Input

Using this method, I'll show you how you can access 5 (or even more) inputs through 1 Arduino pin. These buttons will only be read correctly if only one is pushed at any time though.

As we go through it I'll explain whatever background info you need to know, so as long as you can blink a button, read a switch and read an analog input, you'll be fine. If you can't do any of these, I'll point you in the right direction in the relevant steps as well.

Step 1: Parts List

Picture of Parts List

This is pretty simple:

1 x Arduino (Obviously)
1 x 100K Resistor (Brown Black Yellow)
1 x 1K Resistor (Brown Black Red)
1 x 10K Resistor (Brown Black Orange)
1 x 33K Resistor (Orange Orange Orange)
1 x 68K Resistor (Blue Gray Orange)
4 x Push button switches
Some wires to connect it all

You can use any push buttons you might have lying around, and the resistor values are not critical. More on this later.

Step 2: The Theory - How Buttons Are Normally Read.

Picture of The Theory - How Buttons Are Normally Read.
Lets first look at how you would normally read a button. In its simplest form, you would connect your button like the circuit shown.

As you can see, you need 1 Input pin and 1 resistor per button, and then you can check the state in your Arduino sketch using this:
buttonState = digitalRead(buttonPin);
I'm not showing all the setup etc... Obviously you need to declare everything and set the pin as an input, etc. You can see the full example on the Arduino website.

This is fine if you are only using 1 or 2 buttons, but what if you need 10? That leaves very little IO pins for anything else you might want to do.

Step 3: The Theory - Multiple Buttons on One Pin

Picture of The Theory - Multiple Buttons on One Pin

So how do you put multiple buttons on one pin?

You cheat! The secret to this is using an analog input pin, not digital.

You can read about how the analog input works by going through this Arduino tutorial. Essentially, what you need to know though is that when there is 0V on the analog pin, analogRead() returns a value of 0 and if there is 5V, analogRead will return a value of 1023. For any voltage between 0V and 5V, analogRead will return a number proportional to the voltage.

We can't actually change the voltage that is supplied to the pin (Not easily at any rate, and I'm lazy, so easy is important), but if you remember from Ohms law, V=IR. The current (I) is fixed, which means that we just need to add a resistor between the supply voltage and the analog pin to change the voltage.

For those of you that were getting excited about all the maths that's necessary to calculate the voltages, I'm going to have to disappoint you... I'm lazy, so I don't need maths.

Let's get a bit more practical, and I'll show you why we don't care about the maths. We know that the analog pin reads voltages and we know that we can change those voltages by adding a resistor between it and the supply voltage. We also know that we've gone this far because we want to be able to read switches, so we should probably toss some switches in too.

Now, for those that are interested, To design this, you start with what you know. I know how to connect a single switch to a single input. I wanted 5 buttons, so I duplicated it 5 times. I then simplified it by having a single pull down resister connected to all the buttons, and then simply put resistors between the buttons and the supply voltage and tied all the inputs together.

If you connect each button to the supply voltage through a different value resistor, depending on which button is pushed, the value returned by analogRead would be different, and you can use a bunch of if statements to see which button was pressed. The reason we don't need maths is because we just connect it all up, push the buttons and print the returned values to the serial port.

Step 4: At Last We Can Breadboard It.

Picture of At Last We Can Breadboard It.

Using the previous circuit, build it on a breadboard. I'll show you how I did it, but this is very dependent on which buttons you use, so you'll need to use your imagination. I used micro buttons from old computer mice. I also only had 4 buttons (that worked properly at any rate), so I decided to only do 4 buttons, but the code is set up to handle a 5th button.

Once the circuit is built, you can hook up the GND and 5V to the Arduino, and connect the buttons to analog pin 0 (You can change it, just remember to change it in the sketch).

Remember that I said we don't need the maths? I prefer trial and error. For your resistor values, you should pick values that are fairly evenly spread between an arbitrary lower and higher range. I found that values spread between about 1K and 100K work best. For my resistors, I happened to have 1K, 10K, 33K and 68K lying around, so I used those. If I had a fifth button, i would add a 47K resistor between 33K and 68K.

After I built it, I realize now that the 1K resistor is probably not needed. One of your buttons could be connected directly to 5V, so you need one resistor less than buttons (and the one pull down resistor shared by all the buttons). If one of your buttons is connected to 5V it should always return a value of 1023. So if you want to save a couple of cents, leave out the resistor on button 1.

Step 5: Testing It

Picture of Testing It

Download the attached sketch and upload it to your Arduino. Once it is uploaded, open the serial monitor as well. to test it, watch the serial monitor and then hold down button 1. You will see that the values returned will fluctuate for a bit before settling down in a small band of numbers. Write down the biggest and smallest numbers.

Using the 1K resistor with my button, I got values ranging between 988 and 1011.

After repeating this for all the buttons, I got the following values:
Using the 1K resistor with my button, I got values ranging between 988 and 1011.
Using the 10K resistor with my button, I got values ranging between 910 and 929.
Using the 33K resistor with my button, I got values ranging between 767 and 768.
Using the 68K resistor with my button, I got values ranging between 400 and 609.

The first thing that is clear is that the range is bigger for some buttons. I retested several times with consistent results. I actually replaced the second button because I was getting all kinds of results. I was getting numbers ranging from about 510 all the way through 910, so if you get a huge range of numbers, try a different button.

Once you have these values, you can create a sketch that will read the state of a specific button.

Step 6: Coding It.

Picture of Coding It.

To code it, I simply took the debounced button example and modified that to set a state based on which button was pressed rather than just a simple HIGH or LOW state.

You can download the attached sketch. It is actually quite simple. The first section sets up all the variables and constants we'll use.

const int buttonPin = 0;     // the number of the pushbuttons pin
const int ledPin =  13;      // the number of the LED pin for testing

 
The above just sets up the pins used. Then you need to set up each button and the range of values for that button:

 const int BUTTON1 = 1;
...
 const int BUTTON1LOW = 970;
 const int BUTTON1HIGH = 1024;
...

In the setup, we simply set the pin states and start the serial port (which button is pressed will be written to the serial output):

pinMode(buttonPin, INPUT);
   pinMode(ledPin, OUTPUT);
   Serial.begin(9600);


Then we get to the interesting part. The first part of the program loop is where the magic actually happens, but it simply checks which button was read based on the value we got from analogRead():

int reading = analogRead(buttonPin);
   int tmpButtonState = LOW;             // the current reading from the input pin
  
   if(reading>BUTTON5LOW && reading     //Read switch 5
     tmpButtonState = BUTTON5;
   }else if(reading>BUTTON4LOW && reading     //Read switch 4
     tmpButtonState = BUTTON4;
   }else if
....
   }else{
     //No button is pressed;
     tmpButtonState = LOW;
   }


The next part just debounces the button press. Basically, without this, pressing the button once would appear to the code as multiple presses. Usually this would allow you to use the button as a toggle switch as well, but I'm not doing that.

I'm planning on using the buttons as reset buttons, so I just need to detect when they are pushed and reset a specific variable.

   if (tmpButtonState != lastButtonState) {
     lastDebounceTime = millis();
   }

   if ((millis() - lastDebounceTime) > debounceDelay) {
     buttonState = tmpButtonState;
   }
   lastButtonState = tmpButtonState;


The last part of the program is just a switch statement that executes different code based on which button was pressed. For testing, they all just switch on the built in LED on pin 13.

switch(buttonState){
     case LOW:
     digitalWrite(ledPin, LOW);
     break;
     case BUTTON1:
     digitalWrite(ledPin, HIGH);
     break;
...
}


And that is in essence how easy it is to control multiple buttons. I haven't implemented this into my project yet, so I might do a library for it at some stage if I need to.

Step 7: Improving It

As with all projects, as soon as I'm done, I start thinking about how I can improve it... Here's some thoughts I had:

1. The consistency of the value returned by analogRead is determined by a couple of things:
   - The power supply. The value could vary dramatically if your power is not well regulated. On a regulated supply, maybe a capacitor could smooth the supply some more?
   - The button. I'm not sure why this would be. One thing I noticed is that the values jump around most right as the state changes. My best guess is that it could be caused by the back emf generated when the button is pressed / released. Maybe a diode across the button could clean it up a bit.

Of course, you might be wondering why we need to improve it. After all, it works fine.

If you could get the range of values for each button down to a minimum, you would be able to put a lot more buttons on each analog pin.

For example, if you could get the values for each button within about 60 points, you could easily put 12 buttons on a pin and use each value resistor in the E12 range between 10K and 100K (10k, 12k, 15k, 18k, 22k, 27k, 33k, 39k, 47k, 56k, 68k, 82k and 100k)

You would probably need to use more accurate resistors (or just measure them and use the ones that are close enough to the target value), and you might need to pick your buttons carefully, but the fact that my third button is always in a range of 2 points proves that you should be able to do this.

The second reason is to get it to work with multiple buttons.

Why shouldn't it work with multiple buttons? Once again, I'm not actually going to do the maths (Turns out I'm still lazy), but I am pretty sure that by choosing your resistors carefully, you could figure out which buttons were pressed even if it was more than one.

If you look at the circuit, you can see that by pressing 2 buttons at the same time, you are essentially putting their 2 resistors in parallel. By calling on uncle Ohm again, you have a formula for determining the total resistance for parallel resistors.

For example, if I pressed my second and third buttons, you can see that a 10K resistor in parallel with a 33K resistor gives you a total resistance of  7.6744K (Nope, I googled it - still no maths). This would be easy to pick up in the code. If however I pushed button 1 and 2 though, the resistance for a parallel 1K and 10K resistor would be 900 Ohms, so now we are in the same range as for button 1.

Of course, if you left out the 1K resistor, there would be no way to detect if button 1 was pressed with any other button. Since I don't need to detect multiple button presses, I 'm not going into more details (At this stage at any rate).

Step 8: Final Thoughts

Thanks for reading!  I hope you found this useful. It is my first Instructable, so any feedback - or ratings, wink, wink :) would be appreciated.

Please take the time to vote for me in the Arduino contest if you found this helpful.

This is the first part of a pretty big project. Look out for my next instructables on running lots of LED's on a small amount of pins and running lots of 7 segment displays on a few pins. Once that is done I'm going to have to put it all together.

Hint: I'm planning on running 4 buttons, 20 Led's 4 seven segment displays and an RGB orb on one Arduino. Then I'm going to need to write some software to control it all from my laptop.

If anybody wants me to document all of it, please let me know in the comments.

Comments

pk.jimoc (author)2017-09-25

what happens if you press two or three buttons together?

Stuka39 (author)2017-08-04

That's very nice, but what if you wanted to add an indicator LED to every switch (which turns on when flipping it), how would you do that? And not using any pins on the Arduino... Now that would be extra cool.

AndersB28 (author)2017-01-09

I'm using the 1 wire keyboard calculator from: www.rau-deaver.org/Electronics

It works like a charm for me with an array of 4 x 4 buttons. The program also generates the c-code but with an small error in the #defines - Just remove the equal char to make it running.

/Anders

Jphifi (author)2016-08-28

I want to thank you for such a well documented instructable!

It was very easy to read and understand, if only more people would put the time and effort like you have.

I look forward to reading more of your instructables.

MaximilianoV (author)2016-05-21

This is amazing. Thank you so much! You've just saved me a lot of time and headaches :)

DanS167 (author)2016-04-01

Calculate the resistor:

it<= 40mA

vt= 5v

.

It = (i1+i2+i3+i4+i5+i6+...+in) <= 40mA

.

i1 >= (i2+...+in)

i1 >= it/2;

i1 >= 20mA R1= 5v/20mA = 0,25*10^3 = 250;

.

i2 >= (i3+...+in)

i2 >= i1/2

i2 >= 10mA R2= 5v/10mA = 0,5.10^3 = 500; (R1*2)

.

i3 >= (i4+...+in)

i3 >= i2/2

i3 >= 5mA R3 = 5v/5mA = 1*10^3 = 1k; (R2*2) => (R1*4)

.

i4 >= (i5+...+in)

i4 >= i3/2

i4 >= 2,5mA R4 = 5v/2,5mA = 2*10^3 = 2k; (R3*2) => (R1*8)

.

i5 >= (i4+...+in)

i5 >= i4/2

i5 >= 1,25mA R5 = 5v/1,25mA = 4*10^3 = 4k; (R4*2) =>(R1*16)

WillemN1 made it! (author)2016-02-14

Thanks for the info.

Had some trouble with the normal buttons. This saves me some digital I/0 and it works great. Making an stable Alarm. Some sick basterds are trying to hurt the horses for fun. Iám using the switch through the analog port and make it call the owner with a SMS.Works great because it always measures the analog port.

Great help, thanks!

psmurf56 (author)2015-12-03

One thing I think needs to be mentioned is that this article is using a Pull-Down resistor instead of a Pull-Up resistor. When nothing is pressed the pin is in a low state (0v), this can all be reversed by simply switching where the resistors are on the polarity.

PaulE20 made it! (author)2015-09-30

works perfectly for my little robot - thanks! I used it for two buttons with resistors 10k and 1k - and two times 10k at the end. I get the values 0 for off, 18 for first 155 for only second and around 168 for both.

mekodak (author)2015-09-13

Hi
Can anybody help me.
I want 8 buttons an i want to be able to make multiply button push.
but i dont know how to caltulate it.

I am going for the parelell solution like used in this tuturial.

inventorjack (author)2009-10-28

I don't think this would work so well in industry, due to the fact that resistor values can change over long periods of time, but this is an excellent and cheap technique for personal projects. Thanks for sharing how you simplified the process. I know math can be really tedious for some, and your process cuts all that out. Good instructable!

AlyssonR2 (author)inventorjack2015-08-17

This is certainly the method used in a lot of domestic and office equipment - printer controls, DVD, TV etc. where the cost is shaved by less-than-pennies where possible.

Thanks :) 

I guess you could deal with that in code. If you had button 1 tied to the supply voltage with no resistor, you know its value would be constant. So use button one to start a calibration process where you press each button in turn and the software records the new values for each button.

Of course then you need some form of memory to store the new values and it all starts getting more complicated again. Still, you could make it work if you were desperate enough :)

Of course, for a commercial venture, I would just use a micro-controller with more IO lines.

AlyssonR2 (author)2015-08-17

By connecting the analog input to the centre of a series chain of equal value resistors, and by shorting varying numbers resistors upward and downward, it is theoretically possible to multiplex 1023 buttons on an Arduino.

In practice, a dozen or so could be managed even with 5% resistors.

Savassan (author)2015-05-24

What about taking averages when the button is pressed?

for(int i=0;i<150;i++)

{

sample+=analogRead(A1); //read the value

delay(2);

}

sample=sample/150;

ismadil (author)2015-05-11

I have a project that I am working on where I am monitoring about 25 magnetic contact switches. Your wiring and code represents almost exactly what I am trying to do. I am trying to figure out though, what the upper limit is of switches that can be monitored on one input channel. Basically I have other functions that will require as many open inputs and outputs as possible. I'm thinking maybe I can double up and maybe even triple the resistors at a certain point so that I can get the differentiation in voltage values. Any help is appreciated, thanks!

AmmoMfg made it! (author)2015-04-19

Thanks for posting this. It was a help, as I was thinking down the same lines. I've had this arduino sitting on my desk for a few weeks, but had not done anything with it until tonight. I made the LED blink some, but needed to actually have a physical interface into it.

I ended up going a different way, and used the same value resistor for all 3, I went with a 4-button config, so each button would flow through a different number of resistors, from 0 to 3. Instead of using a breadboard, I used a perfboard and soldered it up. Here's some photos I took of the diagram, and the finished component.

Red is V+

Black is GND

Green is Signal (A0)

AmmoMfg (author)AmmoMfg2015-04-19

Oh, I forgot to mention, I'm using ~5.7K resistors. The output values are all +/- 2

SW1 (closest to the wiring harness) = 1023

SW2 = 969

SW3 = 919

SW4 = 873

Now the next trick, is I need to make another one that all the sensors will plug into, and my whole project will need 1 pin for controls, 1 pin for jam sensors, and I have pins left over for alert lights and an LCD.

Thanks again!

Alderin (author)AmmoMfg2015-05-07

In high school, before the Sound Blaster came out, I built an 8-bit Digital to Analog converter using such a circuit to listen to 8bit music (Amiga .MOD files) through my stereo. This is called a "resistor ladder", though the circuit I followed had one resistor per line PLUS a resistor in-between making it an "R-2R" ladder.

An R-2R ladder would allow for semi-unique analog read values for up to 5 inputs with relatively easy to get high-accuracy resistors (1%), meaning that each combination of pressed switches would have a unique value, for 31 possible input readings (and "none" for 32). More buttons would require higher accuracy (higher cost) resistors (at which point the cost could be higher than just getting another Atmel 328 and using it for a standard matrix key reader and sending results via serial connection).

Another thought is that if you do have an additional resistor for each switch, you'll know the lowest "valid" value, and multiple presses would dip lower than that allowing for detection of this "error" condition if all you want are single key presses.

Thanks for posting! My idle daydreams of using a single analog pin for a full keyboard are now fully researched and laid to rest. :-)

AmmoMfg (author)AmmoMfg2015-04-19

Sorry if I'm filling up the thread with after-thoughts.

If you know the tolerance of your output (in my case +/-2) you can also divide your output by a slightly larger number, which allows you to treat your button output as an over-sample. This prevents having to use a more complex double if statement that covers your tolerance, and allows you to use a case statement.

I also took 32 reads and averaged them together and then divided by 10, which flattened the dataset. Here's my code:

//Definitions
int ledPin = 9;
int ButtonPin = 0;
int count = 0;
int average = 0;


void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.print(F("Welcome to Setup... Setting Pin IO\n"));
pinMode(ledPin, OUTPUT);
pinMode(ButtonPin, INPUT);
//pinMode(TestPin, OUTPUT);
}

void loop() {
//Serial.print(F("Running code loop, setting LEDpin low\n"));
//digitalWrite(ledPin, LOW);
int volt = analogRead(ButtonPin);
count++;
average = (average + volt)/2;

if (count == 32)
{
Serial.println(average/32);
int lightval = (average - 800)/2;
if (lightval < 0) { lightval = 0; }
analogWrite(ledPin,lightval);
count = 0;
average = 0;
}
}

Spirittribe (author)AmmoMfg2015-04-23

I used my setup with an ATTiny85 and it is very forgivable with ranges. From there you can take advantage of the hardware saving and extend that software-wise with a bit of higher-level logic (saves space + aesthetics.) I'm a beginner but after noticing the keypad formation on my Velleman DIY Oscilloscope I gave it another try and VOILA it worked! Like the previous poster said, you notice corporations taking advantage of such circuitry-logic.

AmmoMfg (author)Spirittribe2015-04-23

That's a cool little chip, I'll have to read up on it a bit more. There's a more complicated project I'm working on at the moment that requires quite a bit of data processing (it's a data-acquisition device from a load cell) This might be a good processor for the task.

Spirittribe (author)2015-03-12

Had great success wiring 6 buttons to an analog pin. Four buttons are great to serve as directional buttons and the other two for options. Resistors I'm using are 2.4k, 10k, 5k, 1k, 560, and 220. The 2.4k is not connected to any button but ends the circuit to ground. The first button closest to the 2.4k therefore has no resistor. I have attached a photo of my setup.

LordMekk (author)2009-10-28

 If you kept the resistor values increase by the power of two you could do binary addition and subtraction to get what buttons are pressed.  This is done in computer programing all the time

riaancornelius (author)LordMekk2009-10-28

I thought so too, and initially chose my resistor values that way, but the fact that the resistors are in parallel means that the binary doesn't hold when you connect multiples. For example, if I had 10K, 20K, 40K and 80K resistors on buttons 1, 2, 3 and 4 (To make the maths simpler), I get the following resistances when pressing multiple buttons:
1+2: 6.66K
1+3: 8K
1+4: 8.88K
1+2+3: 5.7K

As you can see, the multiple button presses result in resistances that are all very close together (and close to the button 1 resistance).

I'm wondering if there wouldn't be some way of rewiring the circuit to get the resistors in series when multiple buttons are pressed... Off the top of my head, I don't see an easy way, but it is after midnight here.

bugQ (author)riaancornelius2010-08-12

Your buttons are double-throw switches, right? You should be able to put them in series just fine. All you have to do is short the "off" contact of one switch to the common of the next one, so that there's no resistance when it's not being pressed. Not sure how best to debounce it, though. Anyway, sorry for replying to such an old comment. I have a similar project where this could be verrry useful, though...

bugQ (author)bugQ2010-08-12

It looks something like this...maybe the resistor values have to be tweaked to make it easier to distinguish the voltage readings, but you get the idea.

dylanmc (author)bugQ2015-01-11

Very clever! I gave this approach a go, but in my case, the error in the larger resistors swamped the ability to read the smaller ones.

Further googling turned up the R/2R DAC, which has a similar idea, but is much more robust in terms of accuracy and ease of converting the Analog values on the Arduino to reliable resistor readings. The best description I saw was here: http://www.tek.com/blog/tutorial-digital-analog-conversion-%E2%80%93-r-2r-dac. It works so well, it almost seems magic.

kikiclint (author)riaancornelius2009-10-30

now if you calculated everything with conductances (conductance=1/resistance) they add in parallel.  That would help to do some simple addition calculations.

riaancornelius (author)kikiclint2009-10-30

It would make the maths simpler, but I don't see how that helps practically? 

I have to admit, I haven't worked with any electronics for a while, so maybe I'm missing something obvious, but I don't see an easy way to convert conductance into a voltage that the Arduino would be able to measure.

marcwolf (author)2014-12-16

Many thanks. I've recently brought a tiny 'joystick'

https://www.sparkfun.com/products/10063

And I can now use 6 SMD resistors to create and very tiny control package.

FrancescoB1 (author)2014-11-30

isn't possible to put a 2.2k resistor between GND and each button and 220Ohm resistors in series going to 5v?

i've tried it and the values where all in a range of 10 to the next button AND if i press two buttons the value is of the button before and not between two values

if am i wrong please tell me I'm not an engineer and i can make mistakes...

gtoal (author)2014-03-26

With 2^N-1 identical resistors in a tree, shouldn't you be able to distinguish multiple switch presses for up to N switches? Just parallel them up for X Ohms (1 resistor), X/2 Ohms (2 resistors), X/4 Ohms (4 Resistors) etc. So if you press the switch for 1 resistor at the same time as the switch for 4 resistors, you get the resistance of 5 resistors in parallel (X+X/4 Ohms)and you cannot get that value from any other combination...

gtoal (author)gtoal2014-03-26

This is what I'm thinking of...

UselessBagOfMostlyWater (author)2013-04-22

Thanks for posting this. I had the same idea of using resistors in series before getting here and was glad to see your diagram. I'm wiring an old-school (think industrial arcade game) joystick. In its guts, when you push the lever one way, it causes physical closure of a switch (push up joins two metal contacts on the right; push down and it closes contacts on the left). So really it's just four switches, and physically it's capable of having one or two switches closed at once, but no more.

I'm currently supplying the Arduino's 5V to it, and taking meter readings (disconnected from Arduino) and actual analogRead values (connected to Arduino) to correlate and get an idea of what I'll see. So far it looks logarithmic, suggesting a good spread of resistor values would be 1k, 10k, 37k, and 100k.

At the same time, I have to look up the combined parallel resistances to see what kind of spread they give... Rtotal = (R1*R2)/(R1+R2).

The logarithmic scale, if borne out, suggests higher resistances will give me less variance in analogRead values. Example: choosing R1=220 ohms, and R2=470 ohms, my parallel resistance is 149.86 ohms. But, at that point in the log scale, I expect my analogRead values to be around 220ohms=1002, 470ohms=978, 150ohms=1009. So that split between 1002 and 1009 isn't comfortable enough to account for resistor quality differences.

Instead, if I choose larger values, I hope to get a wider spread of analogRead values to work with.

Rob311 (author)2013-04-08

The all time best use of this trick is on RC controllers (Car, plane, boat). They take one channel and on the TX side, they disconnect it from the stick (which is a potentiometer). They then add 5 or 6 buttons with varying resistors like you did. On the RX side, they plug it into a micro controller that can read PWM (i've done it with a Basic Stamp 2, but an Arduino would work). Now they have taken that 1 channel on the transmitter, and made it into a bunch of buttons that can control anything you want with an arduino.

Sometimes its nice to have the responsiveness of direct PWM on some channels, and 1 or 2 channels of other "actions" at the receiver.

Bam Boy (author)2013-03-09

Hi,

I was just trying to implement your instructable in my project. I connenced the buttons according to your sketch. I used 22K, 33K and 47K resistors and 100K as a pull down resistor.

Now the buttons are working and like whn I press them, I can see the values change in the serial monitor. However, when it comes to calculating the range, the value doesnt fluctuate. Its the same value repeating. Like for button 1, the range is 1023. for button 2 the range is, 838-839, for button 3 it is, 658-659 and for button 4 it is, 503-504.

So, I am confused now. Like should I put down these ranges in my sketch or what?

Can you please help me out :/

Dyte (author)2012-02-04

Thanks a lot for this, helped me a great deal.

OCPik4chu (author)2011-04-14

Wouldnt it be possible to do something like this with a shift register or similar and eliminate the possible conflicts of the resistor values? (not to mention give you more buttons i think)

jonnybeats (author)2010-07-19

Nice tutorial and good method! I'm a bit new to resistance and the like, i need to run eight buttons, does anyone have any idea what resistors to use and what the output values would be. Cheers!

aolinger (author)2009-10-29

Yes, please post the rest of your project plans! Multiplexing LEDS isn't that easy and you demonstrated teaching skills with this project :-).

Thanx a lot,

Alex

riaancornelius (author)aolinger2009-10-29

Thanks Alex. I'm working on the charlieplexed LED's now. Bit of a headache so far... Finally have it wired up properly, now I just need to figure out the code...

Bongmaster (author)2009-10-28

pretty clever that :)

Thanks. You know what they say about necessity :)

About This Instructable

228,784views

131favorites

License:

More by riaancornelius:Controlling 20 Led's from 5 Arduino pins using CharlieplexingAccessing 5 buttons through 1 Arduino pin - RevisitedHow to access 5 buttons through 1 Arduino input
Add instructable to: