I had nothing to do so I picked up my BrainPad and tried some of your sample code.
Leave it up to me and something bad will happen.
(First time use of the BrainPad)
Using Book Electronics - Electronics Analog Inputs.
I received exceptions for:
AnalogInput lightSensor = new AnalogInput(BrainPad.Peripherals.LightSensor, 3.3, 0, 12);
AnalogInput temp = new AnalogInput(BrainPad.Peripherals.TemperatureSensor, 3300, 0, 12);
A first chance exception of type ‘System.InvalidOperationException’ occurred in Microsoft.SPOT.Hardware.dll
Just wondering in the hallways of my little world…
using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware; //AnalogInput
//Serial FTDI GND, RX and TX connections to the BrainPad.
//Must be 3.3v
namespace MFConsoleBrainPad1
{
public class Program
{
public static void Main()
{
Debug.Print(Resources.GetString(Resources.StringResources.String1));
BrainPad.TrafficLight.TurnGreenLightOn();
Debug.Print("Is the GREEN traffic light on?"); //
BrainPad.Display.Clear();
BrainPad.Display.DrawString(1, 1, "Green LED ON", BrainPad.Color.Green);
BrainPad.WriteDebugMessage("GREEN");
//From BrainPad - Book Electronics - Electronics Analog Inputs
//AnalogInput(Cpu.AnalogChannel channel, double scale, double offset, int precisionInBits);
//The BrainPad microcontroller has a 12-bit ADC (int precisionInBits)
//The light sensor connects to PB1 and ADC channel 9.
try
{
AnalogInput lightSensor = new AnalogInput(BrainPad.Peripherals.LightSensor, 3.3, 0, 12);
}
catch (Exception e)
{
Debug.Print("Exception AnalogInput lightSensor: " + e.Message);
//A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.SPOT.Hardware.dll
}
//
try
{
AnalogInput temp = new AnalogInput(BrainPad.Peripherals.TemperatureSensor, 3300, 0, 12);
}
catch (Exception e)
{
Debug.Print("Exception AnalogInput temp: " + e.Message);
//A first chance exception of type 'System.InvalidOperationException' occurred in Microsoft.SPOT.Hardware.dll
}
//
//double tempC = (temp.Read() - 450) / 19.5;
//Debug.Print("Temperature: " + tempC.ToString("F2"));
//BrainPad.Display.DrawString(1, 10, "Temperature: " + tempC.ToString("F2"), BrainPad.Color.Red);
}
}
}
Resources used in Gif