System Halts

This is the code used:

// defines pins numbers const int limitPin = 7; int buttonState = 0; int pressed = 0;

void setup() { // Sets the two pins as Outputs Serial.begin(9600); pinMode (limitPin,INPUT); } void loop() { buttonState = digitalRead(limitPin); if (buttonState == HIGH) { if (pressed == 0){ Serial.println("Ongoing!"); } } else { pressed=1; } delay(1000);

}

Sample Output:

Ongoing Ongoing Ongoing

it stops after 3-5 loops.

Could you please put code tags ? how is pressed ever going to be 0 after it has gone to 1 ?

 // Sets the two pins as Outputs

You could at least make sure that the comments match the code, or vice versa

How is the input wired ?
Do you have a pulldown resistor keeping it LOW until pressed or is it floating at an unknown voltage (which could be read as HIGH) when not pressed

And properly indent (ide -> tools -> autoformat) before posting.

Are you using pullup or pulldown resistors?