Things used in this project

Hardware components:
IngenuityMicro Electron
×1
Software apps and online services:
Nano framework logo 500 trans a1otqnkp8q
nanoFramework Visual Studio extension
nanoFramework GPIO Package
Hand tools and fabrication machines:
Microsoft Visual Studio 2017 Preview 3

Code

Blinking the LEDs on an IngenuityMicro ElectronC#
using System;
using System.Threading;
using System.Diagnostics;

using Windows.Devices.Gpio;

namespace pre3_Electron_1
{
    public class Program
    {
        #region GPIO
        // GPIO
        private const int GPIO_PIN_PA01 = 0 * 16 + 1;  // Led (Blue) for Electron
        private const int GPIO_PIN_PA08 = 0 * 16 + 8;  // Led (Green) for Electron
        private static GpioPin _ledBlue;
        private static GpioPin _ledGreen;
        private static GpioController _gpio;
        #endregion

        public static void Main()
        {
            // Necessary delay to give time
            Thread.Sleep(100);

            // You can remove this line once it outputs correctly on the console
            Console.WriteLine("Program started"); 

            try
            {
                // User code goes here
                
                // Get the GPIO controller
                _gpio = GpioController.GetDefault();
                
                // Initiate the LEDs
                _ledBlue = _gpio.OpenPin(GPIO_PIN_PA01);
                _ledBlue.SetDriveMode(GpioPinDriveMode.Output);
                _ledBlue.Write(GpioPinValue.Low);
                _ledGreen = _gpio.OpenPin(GPIO_PIN_PA08);
                _ledGreen.SetDriveMode(GpioPinDriveMode.Output);
                _ledGreen.Write(GpioPinValue.Low);

                // Do a infinitve loop of blinking the LEDs.
                for (; ; )
                {
                    _ledGreen.Write(GpioPinValue.High);
                    Thread.Sleep(50);
                    _ledGreen.Write(GpioPinValue.Low);
                    Thread.Sleep(50);
                    _ledGreen.Write(GpioPinValue.High);
                    Thread.Sleep(50);
                    _ledGreen.Write(GpioPinValue.Low);
                    Thread.Sleep(50);
                    _ledGreen.Write(GpioPinValue.High);
                    Thread.Sleep(50);
                    _ledGreen.Write(GpioPinValue.Low);
                    Thread.Sleep(250);

                    _ledBlue.Write(GpioPinValue.High);
                    Thread.Sleep(50);
                    _ledBlue.Write(GpioPinValue.Low);
                    Thread.Sleep(50);
                    _ledBlue.Write(GpioPinValue.High);
                    Thread.Sleep(50);
                    _ledBlue.Write(GpioPinValue.Low);
                    Thread.Sleep(50);
                    _ledBlue.Write(GpioPinValue.High);
                    Thread.Sleep(50);
                    _ledBlue.Write(GpioPinValue.Low);
                    Thread.Sleep(1000);
                }
            }
            catch (Exception ex)
            {
                // Do whatever please you with the exception caught
            }
            finally    // Enter the infinite loop in all cases
            {
                while (true)
                {
                    Thread.Sleep(200);
                }
            }
        }
    }
}

Credits

Nanoframework 256 hdm1m5cjfz
Peter Wessel
1 project • 3 followers
Contributor for nanoFramework organisation, long time developer, started with a Motorola 6800 in machine code.
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login