Skip to content

Instantly share code, notes, and snippets.

@hatsunea
Last active August 12, 2022 21:20
Show Gist options
  • Save hatsunea/3a1cde60b5e08ef332d305bcbecee00b to your computer and use it in GitHub Desktop.
Save hatsunea/3a1cde60b5e08ef332d305bcbecee00b to your computer and use it in GitHub Desktop.
using System.Threading;
using nanoFramework.M5Stack;
using Console = nanoFramework.M5Stack.Console;
namespace M5StickLEDSample
{
public class Program
{
public static void Main()
{
Setup();
Loop();
}
private static void Setup()
{
M5StickCPlus.InitializeScreen();
M5StickCPlus.ButtonM5.Press += (s, e) =>
{
Console.WriteLine("M5 Pressed");
Led.Toggle();
};
Console.Clear();
Console.ForegroundColor = nanoFramework.Presentation.Media.Color.White;
Led.Write(System.Device.Gpio.PinValue.High);
}
private static void Loop()
{
while (true)
{
Thread.Sleep(1000);
}
}
private static System.Device.Gpio.GpioPin _led;
private static System.Device.Gpio.GpioPin Led
{
get
{
if (_led == null)
{
_led = M5StickCPlus.GpioController.OpenPin(10, System.Device.Gpio.PinMode.Output);
}
return _led;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment