Alright, so I've been having a problem with a project I named "Button sensor". What I intend for it to do is check to see if pin 9 is receiving current, and for pin 9 to receive current the button it is connected to would have to be closed (pushed down). When pin 9 supposedly does sense current, it would light up a LED connected to pin 7. Problem is, I think something is internally wrong with my Arduino UNO board. Every time I press the pushbutton connected to pin 9 my whole Arduino shuts off. Every time I release, it turns back on. Throughout all of this, the LED connected to pin 7 will not turn on no matter what, but that's more so because the whole circuit board shuts off every time it's supposed to turn on. I tried switching the arguments making it so that if pin 9 was not sensing current, the LED would turn on, and sure enough, it did. This was before I encountered the Arduino shutting off problem. Someone, please help
int pinNine = 9;
int pinSeven = 7;
void setup () {
pinMode(pinNine, INPUT);
pinMode(pinSeven, OUTPUT);
Serial.begin(9600);
}
void loop () {
if (digitalRead(pinNine) == HIGH) {
digitalWrite(pinSeven, HIGH);
} else {
digitalWrite(pinSeven, LOW);
}
}