A tutorial example that blinks an led using C# on dotnet on Raspberry Pi
158
This is a tutorial example that blinks an led on Raspberry Pi.
This has been tested on a Raspberry Pi 3B with docker installed.
In the dockerfile, the C# code is cloned from github, from this repo: https://github.com/Xamtastic/PiBlinky
The Dockerfile is as follows:
FROM anthonyharrison/pi-dotnet:0.2 as builder
WORKDIR /app
RUN git clone https://github.com/Xamtastic/PiBlinky.git
WORKDIR /app/PiBlinky
RUN /root/.dotnet/dotnet restore
RUN /root/.dotnet/dotnet build .
RUN /root/.dotnet/dotnet publish -c Release -o published
Notice that I have put the full dotnet path into the commands - this is because the PATH to it has not been added to the environmental $PATH in the image that the dockerfile is based upon, anthonyharrison/pi-dotnet:0.2
To use this on your Raspberry Pi, either ssh into your Raspberry Pi, or from the desktop cli, you will need to create a container from this image, such as the following:
docker run -it --name myblinkycontainer anthonyharrison/pi-blinky:0.1
This will put you in interactive mode.
Also, you will need to have attached an led between gpio17 and gnd.
Technically, you should probably connect a resister around 200 ohms to the negative lead from the led, however we haven't blown up any leds or pins yet!
Then merely run the command at the cli:
/root/.dotnet/dotnet /app/PiBlinky/published/Blinky.dll
Content type
Image
Digest
Size
324.6 MB
Last updated
about 7 years ago
docker pull anthonyharrison/pi-blinky:0.1