hello, could you help me with my projet???? please

Hi, my name is Israel, I'm from Mexico and I'm working on a project for my school.

I'll try to translate it to english :slight_smile: to have a better comunication with you.

well, the first I want to do is:

Read 10 switchs (push buttons) as inputs of course :smiley:

should I use an array?

I would suggest using arrays, yes.

One for pin number, and one for value. :slight_smile:

ohh tnks

I'm going to use these pins

3.... to 12

can I use them all as inputs?

#define DEBUG 1
#define PULLUP 1
#define SWITCH_PRESSED (!PULLUP)
#define NUMBER_OF_PINS 10

byte switchPin[NUMBER_OF_PINS]={3,4,5,6,7,8,9,10,11,12};
boolean switchValues[NUMBER_OF_PINS] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 };

void setup (){
  for (byte i=0; i<NUMBER_OF_PINS; i++){
    pinMode (switchPin[i],INPUT);
    if (PULLUP){
      digitalWrite(switchPin[i],HIGH);
    }
  }
  if (DEBUG) {Serial.begin (9600);}
}

void loop(){
  for (byte i=0; i<NUMBER_OF_PINS; i++){
    if (digitalRead(switchPin[i])==SWITCH_PRESSED){
      switchValues[i]=true;
    }
    else{
      switchValues[i]=false;
    }
  }
}

well, this is my first code, I edited your code from this topic
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1238637686/3#3

now...

I want to send this array to Flash or Processing

what should I change in the code?

I personally have no idea how, but I have heard this may help:

http://www.arduino.cc/playground/Interfacing/Flash

tnks jezuz, actually i've had some troubles with serialproxy, but maybe i would change flash to processing...mmm i don't know

umm why use almost all of the digital pins? why not use just one analog pins? just get 10 diferent resistors, for each diferent switch and every switch will have it's own number from 0 to 1024!

good work! :wink:

why not use just one analog pins? just get 10 diferent resistors, for each diferent switch and every switch will have it's own number from 0 to 1024!

I thought about doing something like that, but:

  • could changes in the voltage give you different readings.
  • as the circuit, or even a resistor warms or cools could the values change
  • what if more than one button were pressed at once ?

-why would the voltage change?
-i dont think resistors change the resisntance with heat, just huge diferences like -30C 80C, well thermistors do of course,
-i cant answer that, you could try it with just some buttons like 3 just as a test though... :wink:

but i dont think so...

if it does happen, i think with the right software it could be plausible...

good luck! :slight_smile:

if you do the multiple resistor solution you will need 11 resistors (1 resistor to do the voltage dividing)

Here is some more info: Interface multiple keys with one wire and save pins of MCU - Do It Easy With ScienceProg

simultaneous button presses is a difficult issue. While it is possible that you can get a different voltage, it makes resistor selection harder and software longer. Instead of accounting for n+1 different voltage values (for only one press at a time), you would have to now account for n!+1 different values

This is not the most robust way but it would work. I would just use a shift register if I needed more inputs. A more robust method+less software+ no resistor hunting. This method might be even cheaper than finding 11 different resistors with different values that would work. Plus some shift registers account for simultaneous button presses.

Common resistors have a pretty sloppy tolerance.

I noticed that nckelectronic's lcd shield uses an analog resistor ladder to distinguish just five buttons, and the shield works on a clean regulated 5V but does not work when I use a marginal 9V battery. It senses the wrong button values because the voltages are very sensitive to a slight underpower situation.

In short, do digital things the digital way. If you have to reduce how many pins you're using, use a parallel-to-serial shift method, don't try to do something "clever" with an analog resistor ladder.

well, let me explain my idea....

I want 10 inputs to read 10 fingers.

This project is based on "how to learn to type". For this, there's a lot of software online like these Typing Tutorials - Learn & Practice Touch Typing for Free http://www.bbc.co.uk/schools/typing/

They're good, but they can´t read what finger touch the key, so I want to solve that problem using arduino.

Now, I'm using push buttons for the Digital Conecction, but if using analog is better, I could change it.

well, that's all for now :slight_smile:

maybe this image could help

the project has no name, my idea is "MecaFun" ...

meca... in spanish the first 4 letters of "mecanografia" (typing)
fun... just fun lol

i want to this program be like a videogame

here comes another doubt ....

if I want to write an "A"... I push "shift" + "a" so, I would have to use 2 fingers, in this case right little finger for "shift" and left little finger for "a"

would that be a problem to arduino?.... to read 2 inputs pressed at once?

I dont see how this tells you which finger touched which key ?

each finger has his own push button,

for left hand these are the pins

little finger = 12
ring finger = 11
middle finger = 10
index finger = 9
thumb = 8

right hand

little finger = 3
ring finger = 4
middle finger = 5
index finger = 6
thumb = 7

so... for letter "a", only little finger of left hand should press it, this is the 12 pin... if another finger touched letter "a" the program would know there was a mistake because the 12 pin would be LOW and another pin would be as HIGH

i think it'l be fine, i have to customized infrared sensors, and sometimes they have either LOW or HIGH at the same time... it's fine... :slight_smile:

another image, tnks paint ::slight_smile: