My friend Todd stuck four red boxes in the trunk of my car and told me I needed to master embedded programming against one of the three boards in the boxes: Netduino, Arduino, and a FEZ Panda II. This is the beginning of my endeavors into embedded programming. I have tinkered with electronics in the past but could not quote any of the electrical laws. I have been programming for 15 years though most of that with .NET / C# since it was in pre-beta so this should be pretty simple. I decided to blog my learning process in case another electrically challenged developer finds him(her)self in the same position as me.
My first blind project I decided to tackle is blinking an LED on the netduino board with a delay controlled by a variable resistor (knob).
So I grabbed an E-BLOCK POT VARIABLE RESISTOR which has 3 wires: red (positive), black (negative), and white. The red and the black were pretty obvious. I hooked the red up to the 3.3v on the netduino's power block and the black to ground.

The white I figured was the output. This is clearly an analog device so I figured I should hook up the white to the Analog 0 (zero) pin on the netduino.
I saw some articles on flashing the LED on the board and that seemed pretty simple so I just needed to figure out how to get the resistance value from that white wire. I quickly found the AnalogInput class and with some intellisense I found out that the constructor took a Cpu.Pin value to read the analog input. Further object browsing showed me a higher level class supplied in the netduino SDK that humanizes the Cpu.Pin enums. The SecretLabs.NETMF.Hardware.NetduinoPlus.Pins.GPIO_PIN_A0 pin looked like the one I wanted.
Next I found the OutputPort class that let me play with the LED. I passed SecretLabs.NETMF.Hardware.NetduinoPlus.Pins.ONBOARD_LED to the constructor there and this lets me set the LED on and off.
public static void Main()
{
OutputPort led =
new OutputPort(SecretLabs.NETMF.Hardware.NetduinoPlus.Pins.ONBOARD_LED, false);
AnalogInput variableResistor =
new AnalogInput(SecretLabs.NETMF.Hardware.NetduinoPlus.Pins.GPIO_PIN_A0);
while (true)
{
led.Write(!led.Read());
Thread.Sleep(variableResistor.Read());
}
}
Executing the code resulted in the video below. As I turn the knob of the POT the value read from the analog input changes thus changing the value input into the Thread.Sleep() method. So the LED flashing is relative to the amount of resistance on the variable resistor.
The final product, I showed the wife and she was not that impressed ;)
8a97a110-18f4-416a-91e9-8d87941f8d29|1|5.0