Help with Basics (digital input)

Hello everyone,

I am pretty big newbie when it comes to the FEZ. I have never worked with .NET Micro Framework, and it is a little cumbersome for me. I have been doing C programming on AVRs for a long time, and I am very used to doing things at a very low level. I am more comfortable running with the manufacturer’s datasheet (for the LPC2387) and changing registers as described in there. I have tried for a while to get back to the basics, but I don’t think I can do that just yet. So I am going to work with the FEZ as is for now until I can get more comfortable with it.

I was wondering how does basic digital IO work in C#. In “The Beginner’s Guide to C# and the .NET Micro Framework” there is a line:

 OutputPort LED;
LED = new OutputPort((Cpu.Pin)4, true);

for making an OUTPUT called LED, and then stating that the LED is on CPU pin 4, and is true. What I am curious about is this: What is (CPU.PIN)4? Does this pertain to the actual pin on the Domino or what? In the schematic for the Domino, pin 4 is disconnected and it is pin 100 that is connected to the LED. It could be that (CPU.PIN)4 is referring to PWM4, which is on pin 100. I would like some clarity,

and, if for instance on my FEZ Mini, I wanted to make TXD1/E5 (pin 74) toggle on and off, how would I do that?

The beginner guide book is free and takes you through it all in details. Have you seen it?

Basic example for the onboard led You can change whats after fez_pin to any fez labeled pin.

bool ledState = false;

            OutputPort led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, ledState);

            while (true)
            {
                // Sleep for 500 milliseconds
                Thread.Sleep(500);

                // toggle LED state
                ledState = !ledState;
                led.Write(ledState);
            }

It’s much easier if you let Visual Studio and the pin enumeration help you. So if your start with
OutputPort led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.
The intellisense will give you all available digital output pins for your system and you don’t have to worry about the underlying hardware.

Your guess is really close. the pin is also PWM4 but the number 4 is not from PWM4

[url]http://www.tinyclr.com/downloads/Domino/FEZDomino_sch.pdf[/url]

if you look (on the schematic) at the pin 100 or P2.3 that is this pin.
And if you look at the pin next to it there are several pin that label as E3, E5 … etc
but they omitted the E4, which is this pin.

LED = new OutputPort((Cpu.Pin)4, true);

this line of code show you the old and confusing way of specify the pin (which is connected to the LED)

you should not confuse yourself on this for now.
If you read the eBook a little bit further on the next paragraph.
They will show you the easier way to specify the pin by using the emulator. By adding the “Reference”
“FEZMini_GHIElectronics.NETMF.FEZ” and “FEZDomino_GHIElectronics.NETMF.FEZ” which comes with FEZ SDK

Just like:

OutputPort LED; 
LED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, true); 

Hope this help.

Thank you all for the help! I will give this a try later (left my FEZ mini at home, nuts!) and I will ask again if I have any problems, but now the (cpu.pin)4 thing makes sense. Appreciate it!