SD Detect Cerbuino Bee

Hi all, first post here!
I came across a bunch of Cerbuino Bee’s at work and decided to muck around a bit with them, so far I’ve managed to operate the DebugLED and ran a relay from a couple of the GPIO’s but lacking an actual physical button or sensor to hook up to it, I wondered if i could get the presence of an SD card (or lack thereof) into a variable to use as a sort of input switch :stuck_out_tongue:

I’ve searched high and low and came across multiple things that looked like they’d work (i liked sd.IsCardInserted) but none of them seem to be residing anywhere in my references or maybe I’m using the wrong ones…

Documentation on Cerb-family developing also mentioned: “To detect whether or not an SD card is inserted in the onboard connector, you can sample pin PC2 with the pull-up resistor enabled.” but I have no clue where to even look for that…

I’m a novice at programming, started with C#/Visual Studio 2 days ago when I found these things so any help is appreciated!

2 Likes

@ Albert Wintervacht - 2 Days ago?

welcome to the community Albert

Hopefully you’ve stepped through the full instructions in the “Support -> .Net Micro Framework” from the above menu to install all the parts that you need (that’s likely given you’ve done some coding already). Can you confirm which GHI SDK version you have installed ?

Irrespective of that, PC2 is the pin that’s used to detect the “switch” in the SD card. If you simply use a reference to “GHI.Pins” (in the “references” part of your project control pane on the RHS of the VS page) then you can use IntelliSense to find the reference to GHI.Pins.PC2. You’ll need to look at creating a DigitalInput object to be able to read the state.

But you can do the same thing with any pin on your header. If you use a simple wire that can be inserted into the header on your chosen pin, and then you leverage a pull-up setting in your input pin creation, then you can simply connect that wire to GND to simulate a switch. (you could reverse the wiring too - use a pull-down in input pin creation, and tap the wire to 3v3 pin).

looking forward to hear what else you continue to build !

2 Likes

Yes, is that a bad thing?
I’ve done a little programming in Java before but this is my first experience in C# and I’m still finding my way around Visual Studio right now.
References were a great unknown to me so i was wondering why at first none of it would work!

I have GHI Electronics NETMF SDK 2015 R1 installed, which in hindsight maybe was a mistake ::slight_smile:
The 2016 version wouldn’t install properly because of missing dependencies, so I tried the 2015 version which told me the same thing… Manually installed the missing things and then the 2015 SDK again and it worked, so I guess I could have installed the 2016 SDK just as easily.
Is there a big advantage to having the newer version?
Full disclosure on software used: Visual Studio Community 2015, MicroFramework 4.3, netmfvs2015.vsix, FEZ Config and STDFU Tester.

GHI.Pins.PC2 is not something that exists in the references I have, IntelliSense suggests .FEZCerbuinoBee.[…] after .Pins… This is why I feel like I might have done something wrong in installing the frameworks somewhere but hey, the rest seems to work just fine :slight_smile:
The headers do work like a charm though, so I’m gonna go ahead and find a wire somewhere to simulate a button press on one of the headers.

I don’t really have a plan for this thing yet, I just like tinkering with the combination of hard- and software, so all I have right now is basically a complicated digital light switch if I hook the relay up to a lamp or something :smiley: but if it works I’m happy because I’ll have wired and coded everything myself so that’s fun!

Thanks for the help, much appreciated!

@ Albert Wintervacht - No, its impressive. It also goes to prove how fast and easy the NETMF platform is :smiley:

1 Like

two things.

VS2015 isn’t technically supported yet. You should proceed with caution. There’s at least one major issue (with a workaround posted in codeshare here) and possibly other unknown issues.

References are key, but USING is also a key. If you don’t list a “using” statement (that you’ll see in your example code) you have to fully qualify the reference to the assembly you included in the references section. You can explore the namespaces using solution explorer against the reference you’re interested in. Then, you can “shorthand” the reference by saying “using xxxxxx” and that will allow you to not have to type the xxxxxx portion any longer, it will auto resolve.

You’re right about GHI.Pins.PC2 - depending on the SDK installed, there was a change to how the pins were named, you need to include CerbuinoBee in the middle of the name so that it differentiates what board you have.