Variable switch with push button

I want to change the value of a variable “Komma” with a push button.
Each time you click the button the value is to change.

  1. Click Komma = 5,
    2nd click Komma = 1,
  2. click Komma again 5 and so on. A simple Swap-Function.

In VB I use the Int - Function on every Button Click:

a=a+1
if a/2=int(a/2) then  
 Komma=5 
else
 Komma=1
end if

How to do it on the Arduino? Was looking for swap function but found nothing that helped me.

if button becomes pressed
  increment counter
  if counter % 2  //modulo operator
    Komma = 5
  end if
  else
    Komma = 1
  end else
end if

Many Thanks. problem solved :)

Skino: Many Thanks. problem solved :)

For future issues, you might look at the examples. This particular issue is addressed in the State Change Detection example.

Hi,

I think a problem is the title of some examples and tutorials.

"State Change Detection " probably means jibberish to a noob, hence members and the forum to assist.

Tom..... :)