Skip to content

1.3 Lab 3

gloveboxes edited this page Apr 10, 2015 · 1 revision

#LAB 3: SENSING THE WORLD

This lab reads the current levels from the Temperature and Light Sensors.
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. If the program is still running from Lab 2, then click the stop button first. You will not be able to edit the Program.cs file while the code executes.

  3. Follow the notes in the Lab 3 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. The code will deploy to the Netduino

  6. The red LED should start blinking

  7. In Visual Studio press Alt+2 to switch to the Output screen. You will see the sensor data displayed in JSON format.

    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 (SensorTemp temp = new SensorTemp(Pins.GPIO_PIN_D8, 10000, "temp01"))
                using (SensorLight light = new SensorLight(AnalogChannels.ANALOG_PIN_A0, 1000, "light01"))
                using (rgb = new RgbLed(Pins.GPIO_PIN_D3, Pins.GPIO_PIN_D5, Pins.GPIO_PIN_D6, "rgb01")) {
    
                    while (true) {
                        Debug.Print(light.ToString());
                        Debug.Print(temp.ToString());
    
                        rgb.On(RgbLed.Led.Red);
                        Thread.Sleep(500);
                        rgb.Off(RgbLed.Led.Red);
                        Thread.Sleep(500);
                    }  // End of while loop
                }
            }
        }
    }
    
Clone this wiki locally