i put some buttons and connected to ground , my question how to detect if the pin is connected to ground to know that the button was pressed , what is the code that i need to write , i use the digital pin 10+11 for the two buttons . thanks again
Use the digitalRead() function. If it returns LOW then assuming that you have wired the button correctly and either have a pullup resistor or used INPUT_PULLUP in the pinMode() for the pin to keep it normally at 5V then you know that the pin has been connected to GND by pressing the button.
If that does not make sense then please post a picture of your circuit
When you press the button pin 3 is taken to GND but what voltage is it at when the button is not pressed ? You have no pullup resistor in the circuit and you have not posted your code so we cannot see whether the pinMode() for pin 3 is set to INPUT_PULLUP to hold it HIGH until the button is pressed.
i put some buttons and connected to ground , my question how to detect if the pin is connected to ground to know that the button was pressed , what is the code that i need to write , i use the digital pin 10+11 for the two buttons . thanks again
Arduino IO pins that are
pinMode( pin_number, INPUT_PULLUP );
get 5V through 20K to 50K Ohm internal resistor, very weak current that is safe to ground.
You can make a switch by sticking a jumper into the INPUT_PULLUP moded pin hole and "close the switch" by grounding it on the USB port housing, it's how I make dirty button for testing button debounce code. A closed switch will make the pin LOW and an open switch will make the pin HIGH.
You don't need to supply the pin with 5V through the switch and have a pulldown resistor (only works if the mode is INPUT, not INPUT_PULLUP) just ground the pin through your button or not.