How can i add a toggle on off button to this? i tried a lot but it didn't work. I just want to counter go up only 1 times after i press it. And it wont keep going up while im holding it down
It looks like you are using your button on Arduino Pin 12 which is PB4 on PORT B. You must configure PB4 pin mode (DDRB) as INPUT (or INPUT_PULLUP) using a "mask" on PINB. You are using PORTx and masking bits in your code... here is a chart showing PINx also...
DDRxn PORTxn state
0 0 INPUT
0 1 INPUT_PULLUP
1 0 OUTPUT LOW
1 1 OUTPUT HIGH
Practice binary mathmagic. I understand your meaning, knowing the IDE will do better bitmath than I will. It is akin to ham with cw... why? other than enjoying "Hello, World!" in ham.