High signal on GPIO

LucySLucyS New Member Posts: 1

Hello,

I am using the UP Squared board with Windows 10 IoT and working on a C + + project that uses the input signal of a sensor, but it always stays high. Here's the sample code that displays the status of the pin, but shows only a high level. I am stuck at this for a few days and any help will be appreciated!

MainPage::MainPage()
{
InitializeComponent();

InitPin();

if (pin != nullptr)
{
    timer_ = ref new DispatcherTimer();
    TimeSpan interval;
    interval.Duration = 1000 * 1000 * 10;
    timer_->Interval = interval;
    timer_->Tick += ref new EventHandler<Object ^>(this, &MainPage::GetPinValue);
    timer_->Start();
}   

}

void CaptureImage::MainPage::InitPin()
{
auto gpio = GpioController::GetDefault();

// Set up our GPIO pin for setting values.
pin = gpio->OpenPin(LED_PIN);

// Configure pin for input.
pin->SetDriveMode(GpioPinDriveMode::Input);

}

void CaptureImage::MainPage::GetPinValue(Object ^sender, Platform::Object ^args)
{
pinValue = pin->Read();

SensorValue->Text = pinValue.ToString();    

}

Best regards!

Sign In or Register to comment.