Answer the question
In order to leave comments, you need to log in
Weird exception on Raspberry Pi 3 + Windows 10 IoT Core, what should I do?
Hello.
There is a Raspberry Pi 3, by pressing the physical button, a photo from the webcam should be taken. Clicking this button throws the exception "Pin ' is currently opened in an incompatible sharing mode. Make sure this pin is not already in use by this application or another application".
As I understand it, the application thinks that the pin is already taken by some other application. But the fact is that right now there are no other applications on the raspberry, with the exception of the already built-in ones.
I don't know what to do, please help.
The code:
private const int BUTTON_PIN = 6;
private GpioPin buttonPin;
public MainPage()
{
this.InitializeComponent();
InitGPIO();
}
private void InitGPIO()
{
var gpio = GpioController.GetDefault();
// Show an error if there is no GPIO controller
if (gpio == null)
{
GpioStatus.Text = "There is no GPIO controller on this device.";
return;
}
buttonPin = gpio.OpenPin(BUTTON_PIN);
// Check if input pull-up resistors are supported
if (buttonPin.IsDriveModeSupported(GpioPinDriveMode.InputPullUp))
buttonPin.SetDriveMode(GpioPinDriveMode.InputPullUp);
else
buttonPin.SetDriveMode(GpioPinDriveMode.Input);
// Set a debounce timeout to filter out switch bounce noise from a button press
buttonPin.DebounceTimeout = TimeSpan.FromMilliseconds(50);
// Register for the ValueChanged event so our buttonPin_ValueChanged
// function is called when the button is pressed
buttonPin.ValueChanged += buttonPin_ValueChanged;
GpioStatus.Text = "GPIO pins initialized correctly.";
}
private void buttonPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e)
{
takePhoto();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question