Community

Simple button readout not working?

I have connected D04 to a pushbutton. Pullup using an external resistor of 3K9. Verfied with a voltmeter that the voltage becomes 0 when presssed and 3.3 when released on pin DO4.
I use to code below:

using System;
using System.Threading;
using Meadow;
using Meadow.Devices;
using Meadow.Foundation;
using Meadow.Foundation.Leds;
using Meadow.Foundation.Sensors.Buttons;
using Meadow.Hardware;

namespace HelloMeadow
{
public class MeadowApp : App<F7Micro, MeadowApp>
{
IDigitalInputPort input;

    public MeadowApp()
    {
        input = Device.CreateDigitalInputPort(Device.Pins.D04, debounceDuration: 20);
        input.Changed += Input_Changed;
        Console.WriteLine("Started...");
    }

    private void Input_Changed(object sender, DigitalInputPortEventArgs e)
    {
        Console.WriteLine("Changed: " + e.Value.ToString()); //+ "); Time: " + e.Time.ToString());
    }

}

}

After deploying it in VS2019 is shows “Started…” on the console. But pressing the button doesn’t return the "Changed: " message. I commented out the e.Time.ToString() part because this was not recognized by the compiler.
Why doesn’t this work?