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++;
}

Google "Floating pin". You have to have something connected to a pin that you intend to read. If it is connected to nothing then it will pick up whatever stray noise it can and can read anything.

counter needs to be volatile if it is going to be used in the ISR.

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++;
}

avr_fred:
oid brojac(){
volatile counter++;
}

Not even close...

More like:

 volatile int counter = 0;