How to read GIPIO sensor/switch

I just started with ESPhome and arduino’s in general. I want to use an ESP01 to flash a light and to read whether a switch is on/off. I have connected the esp to my arduino and I am able to turn on/off a led. I noticed that this only works when using GPIO1. I also noticed that when I turn on the (external Led), the onboard Led turns off and vice versa.

Then I connected a push button to my arduino. When it’s pressed it sets the digital pin connected to the ESP to HIGH. I want to see in my dashboard when this button is pressed. Therefor I added this “sensor / switch” to my dashboard, but it always shows me that it is switched off.

I used the code below to configure my esp8266. What am I doing wrong?

esphome:
  name: alarmklokyori
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: xxx"
  password: "xxx!"
  use_address: "192.168.1.xx"
  manual_ip:
    static_ip: 192.168.1.xx
    gateway: 192.168.1.1
    subnet: 255.255.255.0
    dns1: 192.168.1.1

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Nodetest Fallback Hotspot"
    password: "MmOYpJXEjU0Z"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "xx

ota:
  password: "xx"
  
switch:
  - platform: gpio
    name: "Blauw Lampje Yori"
    pin: 1

binary_sensor:
  - platform: gpio
    name: "Alarm Knop Yori"
    pin: 2