on/off switches in resistor voltage divider

I thinking this:
Switch #1 1
Switch #2 2
Switch #3 4
Switch #4 8
Switch #5 13
Switch #6 29
So, the Arduino card can detect which switches are activated, for example #1 to #5 give me 28 as a value which the Arduino card can read.
#1 to #6 is 57 as the value if I activated all together. If #2 and #5 and #6 are activated, I get 44 as one value to the Arduino card.

I am doing this to save pins. If I am using each pins; that would be need maybe 400 pins, so I am using maybe 30 pins.

So, which resistors do I need ?

Look it up in Learning. Here is one example:
http://forum.arduino.cc/index.php/topic,20125.0.html

This example can detect 1 of 12 (only one switch at a time) on an analog input

/*******************************************************
Defines 12 switch resistornet connected til A0
12 resistors,   series : 2k2, 180, 220,270,330,470,560,820,1k2,1k8,3k3 og 8k2
2k2 connects to 5V, other end til A0 and 180R. After A0 downwords connects a switch to gnd
Key 0 will  give analog reading 0
Key => 1 ca 77, Key 2: 157, Key 3: 239, Key 4:320, Ket 5: 410, 
// knapp (norwegian) = key
Knapp 6: 491, Knapp 7: 577, Knapp 8: 663, Knapp 9: 743, Knapp 10: 825 og Knapp 11: 908
If no key is pressed, you will read near  1023

Key find = integer of ((analog reading+ 41) /  82.5)


********************************************************/
#define analogPin 0
void setup()
{
 Serial.begin(9600);        // start seriell kommunikasjon
 Serial.println("Trykk en knapp");
}
 
void loop()
{
  while (knapp()<0); // vent til det er trykket på en knapp
  Serial.println(knapp()); // skriv knappenummer på skjermen
  delay(500); // ent 1/2 sek før du leser om igjen
}

int knapp() // returnerer knappenummer 0..11 eller -1 dersom ingen knapp er trykket ned
{
  int lestAnalogVerdi = analogRead(analogPin);      // les verdi fra sensoren
  int nummer=int((41.0+lestAnalogVerdi)/82.5);
  if (nummer<12) return(nummer); 
  return(-1);
}

knut_ny:
This example can detect 1 of 12 (only one switch at a time) an an analog input

/*******************************************************

Defines 12 switch resistornet connected til A0
12 resistors,   series : 2k2, 180, 220,270,330,470,560,820,1k2,1k8,3k3 og 8k2
2k2 connects to 5V, other end til A0 and 180R. After A0 downwords connects a switch to gnd
Key 0 will  give analog reading 0
Key => 1 ca 77, Key 2: 157, Key 3: 239, Key 4:320, Ket 5: 410,
// knapp (norwegian) = key
Knapp 6: 491, Knapp 7: 577, Knapp 8: 663, Knapp 9: 743, Knapp 10: 825 og Knapp 11: 908
If no key is pressed, you will read near  1023

Key find = integer of ((analog reading+ 41) /  82.5)

********************************************************/
#define analogPin 0
void setup()
{
Serial.begin(9600);        // start seriell kommunikasjon
Serial.println("Trykk en knapp");
}

void loop()
{
 while (knapp()<0); // vent til det er trykket på en knapp
 Serial.println(knapp()); // skriv knappenummer på skjermen
 delay(500); // ent 1/2 sek før du leser om igjen
}

int knapp() // returnerer knappenummer 0..11 eller -1 dersom ingen knapp er trykket ned
{
 int lestAnalogVerdi = analogRead(analogPin);      // les verdi fra sensoren
 int nummer=int((41.0+lestAnalogVerdi)/82.5);
 if (nummer<12) return(nummer);
 return(-1);
}

I see that
Jeg ser det.
Now I am reading the example who Steinie44 posted.

I have been read the topic that Steinie44 posted which is a good proposal; but, it requires more than one pin and a lot of time to get it working.

To Knut: That's I am not asking for and I have had same issue as you might thinking. Then I asked in earlier topic for help and I got the help to draw a correct schematic.
So, now I am asking for which resistors do I need. My idea is finished but I don't know which resistors I need.

Depends on how you do it. Some require each one to be doubled, and some you can use the same value for all of them. I like all the same value.

I need double values.

Post a schematic of how you propose to use the resistors, the. We can help with the values.
Basically you can do this technique with all the same resistors or different ones.
Do you need to detect multiple presses?

Grumpy_Mike:
Post a schematic of how you propose to use the resistors, the. We can help with the values.
Basically you can do this technique with all the same resistors or different ones.
Do you need to detect multiple presses?

How do I this technicqye with all the same resistors ?
Yes, I need to detect multiple presses.

Here's attachment.
I am not sure if the resistors value is correct.

Quiet here... bump.

400 pins?
Do you try to have 400 input values?

You start an binary series 1, 2, 4, 8. But next become 13 not 16? Then 28 not 32?

With a digital binary input you need 9 pins to represent 512 values

With 3 binary coded decimal thumbwheel switches you can have 1000 values of your input (0-999) using 12 pins.
With multiplexing you can reduce it to 7 pins but then it needs 12 diodes instead.

Can't understand why you are afraid of using pins?

Pelle

You are not going to do what you want with that circuit., that sort of circuit is only good for a single button detection. It is impossible to work out resistor values to do what you want.

To acheave multiple pressing detection the circuit you need is known as a R2R ladder. It has only two values of resistor one with a value R and one with a value twice that 2R. In fact you can make it with only one value of resistor and have two in seriese for the 2R.

Great idea Mike
http://canada.newark.com/bourns/4310r-r2r-103lf/resistor-ladder-n-w-10-10kohm/dp/75K9799

Yes, a great idea.
Digital ---> analog ---> digital :wink:

Pelle

Pelleplutt:
Yes, a great idea.
Digital ---> analog ---> digital :wink:

The idea is that the path is narrower in the middle....

Qwseyvnd:
If I am using each pins; that would be need maybe 400 pins,
...
I need double values.

This is unlikely to work.

It might sound good in theory, but ...

Why don't you tell us what you're trying to make/achieve, not what you're doing. That way nobody will waste any time giving non-applicable answers.

that would be need maybe 400 pins

That implies you need a 20 by 20 matrix of switches.

Grumpy_Mike:

that would be need maybe 400 pins

That implies you need a 20 by 20 matrix of switches.

I spotted that, too!

Sounds to me like somebody's trying to make a MIDI controller (or something similar).

What are you trying to do?