I have problem determining if my Arduino Uno is working corectly

Hello,

am new to arduino, i wrote simple program with interrupt and on serial monitor am getting weird things.

so if someone can help me. am running board without any jumpers switches and i get response on serial monitor. its doing counting with out external hardware to trigger interupt

int counter = 0;

void setup(){
Serial.begin(9600);

pinMode(2, INPUT);
attachInterrupt(0, brojac, CHANGE);

}

void loop() {

Serial.println(counter);

}

void brojac(){
counter++;
}

To fix the floating input, change

pinMode(2, INPUT);
to
pinMode(2, INPUT_PULLUP);

This will stop the counting until you pull pin 2 low with a switch connected between pin 2 and ground.

You may see multiple counts with one switch activation, this is called switch bounce. Due to this behavior, it is generally a bad idea to read switches using interrupts. Interrupts are also very difficult to debug so it is best to avoid them, especially when you're new to Arduino.

Don't forget DeltaG's other fix:

oid brojac(){
volatile counter++;
}