Go Down

Topic: 5 buttons on one pin. (Read 759 times) previous topic - next topic

S_Flex



The resistors are connected to the buttons in a daisy chain see picture.
Can I ask if I can use 5 pins on the Arduino to go to the same transistor or would that cause problems. I have no trouble controlling 5 separate pins with the buttons like this but would like to know if they all connected to the same output and say 2 buttons were pressed at the same time.


  if (val >850 && val < 865 ) digitalWrite (Pin8,  HIGH); // turn on test led 1
  if (val >890 && val < 910 ) digitalWrite (Pin9,  HIGH); // turn on test led 2
  if (val >930 && val < 940 ) digitalWrite (Pin10, HIGH); // turn on test led 3
  if (val >970 && val < 980 ) digitalWrite (Pin11, HIGH); // turn on test led 4
  if (val >1015 && val < 1030)digitalWrite (Pin12, HIGH); // turn on test led 5
Jeremy




Shouldn't that 68k resistor be 10k to protect the pin?

jezza103

Hi I might be getting somewhere. I think I have to use time for the program to work. One button and length of time it was pressed for. I can get 5 leds to light one after the other depending on how long I press for. now I need to work out how to get the different charge limits into the sketch, and that is where I am falling down. But I am getting somewhere. Not bad for a 47 year old who had never tried out anything to do with electronics 18 months ago.
Now Programming is another matter. They say "you can't teach an old dog new tricks" Well that may be so but with a little advice I might just learn a thing or two.
Regards to you all
Jezza :)
There are times when electronics projects are like Women. Just when you think everything is fine the blow up in your face :-0

liudr

The "new trick" is to realize button push is not a state (such as value between 100 and 200). Rather button push is a change of state (such as from 0 to between 100 and 200) within some reasonable time frame (20 ms so to debounce random contact from bouncing around). If you want true button actions in your program, you need to set up a variable to track state of the input and detect change of state.

Go Up