Driving the Output
The output from the flashlight will be a lamp of some kind that will be controlled by a pin configured as an output on the target hardware. The connection to be used on a genuine device would be chosen when the circuit that controls the lamp is designed.
Creating an Output-Port Object
Most pins on a device are general purpose in that whether they are input or output is controlled by software. To control a simple device like the lamp on our flashlight, we can use an instance of the OutputPort
class, which is provided as part of the .NET Micro Framework. It is an object whose job is to manage an output connection to an external device. The code to create the object is as follows:
OutputPort lampOutput = new OutputPort(lampPin, false); ...
Get Embedded Programming with the Microsoft® .NET Micro Framework now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.