程序截圖
實拍
性能消耗非常小的,就是對ROM有要求,SDK+程序佔了40M
步驟1:按照鏈接教程刷入系統
步驟2:修改以太信息
步驟3:使用ssh登錄系統
步驟4:搭建dotnet環境,使用手動的方式
先下載運行時包
下載 .NET 6.0 Runtime (v6.0.28) - Linux Arm32 Alpine Binaries (microsoft.com)
在 Linux 上不使用包管理器的情況下安裝 .NET - .NET | Microsoft Learn
安裝後輸入dotnet --info驗證
步驟5: 部署程序
代碼:
要求安裝nuget(System.Device.Gpio)
Console.WriteLine("Hello, World!"); using (GpioController controller = new GpioController()) { int pin = 55; // GPIO Pin number controller.OpenPin(pin, PinMode.Output); while (true) { controller.Write(pin, PinValue.High); // Turn on the LED Thread.Sleep(1000); // Wait for 1 second controller.Write(pin, PinValue.Low); // Turn off the LED Thread.Sleep(1000); // Wait for 1 second } }
遇到的問題
Process terminated. Couldn't find a valid ICU package installed on the system. Please install libicu using your package manager and try again. Alternatively you can set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support. Please see https://aka.ms/dotnet-missing-libicu for more information.
處理方法
這個錯誤表明系統找不到安裝在系統上的有效 ICU(International Components for Unicode)包。爲了解決這個問題,您可以按照以下步驟之一操作: 安裝 libicu:您可以通過包管理器安裝 libicu 庫。在 Alpine Linux 上,您可以使用 apk 包管理器安裝 libicu。運行以下命令來安裝 libicu: apk add icu 設置 System.Globalization.Invariant 爲 true:另一種解決方法是設置配置標誌 System.Globalization.Invariant 爲 true,這樣可以在不支持全球化的情況下運行。您可以通過設置環境變量或在應用程序中進行配置來實現。示例: export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true
發佈後複製到系統中即可正常運行
步驟6:接入LED燈
GPOI圖:
55 號GPIO 3.3V所以需要掛上一個電阻,50-200歐姆即可
成功點亮
拿C#寫IOT簡直是降維打擊