#include <TinyDebug.h>
#include <avr/io.h>
#include <avr/delay.h>


#define ledPin PB0
#define buttonPin PB3
uint8_t ledState = 0;
uint8_t buttonPresent; // variable to show button state
uint8_t buttonPast = 1; // vaiable to show button state
uint8_t count = 0;

int main(void) {
  Debug.begin();
  
  // output Led pin
  DDRB = 0b00000000; // set all of DDRB as input
  DDRB |= (1 << ledPin); // set Led as output

  // input Button pin
  DDRB &= ~(1 << buttonPin); // set Button as input
  PORTB |= (1 << buttonPin); // enable pull-up resistor on Button

  while (1) {
    // buttonPresent = bit_is_clear(PINB, buttonPin); // or use line below
    buttonPresent = (PINB & (1 << buttonPin)) == 0;
    Debug.print("buttonPresent "); Debug.println(bit_is_clear(PINB, buttonPin));

    if (buttonPast == 0 and buttonPresent == 1) {
      if (ledState == 0) {
        PORTB |= (1 << ledPin);
        ledState = 1;
        count ++;
      }
      else {
        PORTB &= ~(1 << ledPin);
        ledState = 0;
      }
    }
    buttonPast = buttonPresent;
    Debug.print("led state = "); Debug.print(ledState);
    Debug.print(" count = "); Debug.println(count);

    _delay_ms(100);
  }
}

ATTINY8520PU