This is a small example how to use .net Platform Invoke with PIGPIO library.
This small example supposes that:
- GPIO pin 23 connected to Anode (+) of LED. Cathode (-) of LED is connected to GND via 220Ω resistor.
- GPIO pin 24 is connected to one button leg. Second button leg is connected to GND
When program stars, it waits the button push. As button is pushed, LED starts blinking. Second button push switches off the blinking.
This project uses .Net 9. Instructions how to install .Net SDK to your Raspberry Pi you can find here
If the instructions don't work (as in my case). Instructions for manual .net installation:
- Go to the official website And click
Download binaries -> Arm64
link. Copy the direct link from the download page. - Download the distribution on Pi:
wget <URL_OF_THE_ARM64_TARBALL>
- Unpack
tar
pack:
sudo mkdir -p /usr/share/dotnet
sudo tar -zxf dotnet-sdk-9.<whatever version is in downloaded file>-linux-arm64.tar.gz -C /usr/share/dotnet
- Setup symbolic link:
sudo ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
- Check if everything is OK
dotnet --version
- I have set up my RPI as headless device
- Set up SSH Public Key Authentication
- Debug code in VS Code on my dev machine via Remote SSH