Skip to content

1.2 Lab 2

gloveboxes edited this page Apr 10, 2015 · 1 revision

##LAB 2: BLINKY

Blinking an LED is the “Hello World” of Microcontrollers. It is useful to ensure that everything is setup correctly and that Visual Studio can communicate with the Netduino.

Ensure the Netduino is connected to the PC using the USB cable and then follow these steps.

  1. Review the code below. On completion of this lab, your code should be the same

  2. From Visual Studio open the MakerDen solution

  3. Follow the notes in the Lab 2 (found in the Lab Code folder) and copy and paste the code in to Program.cs

  4. Press F5 or the click the Start button from the toolbar to run the code on the Netduino

  5. It will take approx. 30 seconds for the code to deploy to the Netduino

  6. The red LED will start blinking when the program executes (if it blinks blue then you have put the LED in the wrong way round)

  7. You can also set breakpoints and step through the code as it executes.

    using Coatsy.Netduino.NeoPixel.Jewel;
    using Glovebox.Adafruit.Mini8x8Matrix;
    using Glovebox.MicroFramework.Sensors;
    using Glovebox.Netduino.Actuators;
    using Glovebox.Netduino.Sensors;
    using Microsoft.SPOT;
    using SecretLabs.NETMF.Hardware.NetduinoPlus;
    using System.Threading;
    
    namespace MakerDen {
        public class Program : MakerBaseIoT {
    
            public static void Main() {
                // main code marker
    
                using (rgb = new RgbLed(Pins.GPIO_PIN_D3, Pins.GPIO_PIN_D5, Pins.GPIO_PIN_D6, "rgb01")) {
    
                    uint LedSelector = 0;
                    while (true) {
                        rgb.On((RgbLed.Led)(LedSelector % 3));
                        Thread.Sleep(500);
                        rgb.Off((RgbLed.Led)(LedSelector % 3));
                        Thread.Sleep(500);
                        LedSelector++;
                    }  // End of while loop
                }
            }
        }
    }
    
Clone this wiki locally