Main Site Documentation

Gadgeteer - using eblock Piezo



[quote]LED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, true);
because FEZ_Pin is not recognised “using” any of the GHI namespaces, whether referenced or not.
Instead I got the diode blinking on a button attached to socket X with this line:
LED = new OutputPort((Cpu.Pin)5, true);

Hi, I’m new to Gadgeteer/FEZ - hoping someone could give me some direction on this. I’m using the Spider and have the eblock extender and some modules - trying to get the piezo to work.

In the previously stated issue, what reference should be used for FEZ_Pin? I’m getting the same error. Or if it’s to be done a different way, are there some code samples?

What I found is (with FEZ_Pin having the issue):
public Piezo(FEZ_Pin.PWM pin)
pwm = new PWM((PWM.Pin)pin);

I see that FEZ_Pin is in the FEZmini_… reference, but that won’t work.

I apologize if this is a dumb question. I’m reading a couple of the beginner guides and searching for answers, but not quite finding the answers.



@ jspy66

See my reply here:

Basically, you should be able to use the code from:

to successfully drive an eblock Piezo from FEZ Spider. Make sure you’re using the Gadgeteer project template as a starting point.


Thanks devhammer.

I think I initially made a wrong turn by using the driver download ( that was in the catalog. I’m now assuming that these drivers are for the FEZ mainboards, but not the Gadgeteer mainboards?

I’ve been messing around with my Spider, the piezo and other modules for a few days and probably spending way too much time on the piezo version of the Star Wars Imperial March. It’s all good practice, though. Still need to do some more reading.


@ jspy66

Glad to hear that you’re enjoying working with the Spider. It’s a fun little board.

The driver on the eblock page could probably be adapted to work with the Spider, the main difference is in how you instantiate the PWM output, and tell it which pin to use. In the eblock driver, it looks like this:

pwm = new PWM((PWM.Pin)pin);

But for Gadgeteer, using the eblock expansion module, it looks more like this:

Piezo1 = eBlockExpansion.SetupPWMOutput(GT.Socket.Pin.Nine);

Once the PWM/Piezo is instantiated, the code is pretty much the same from there.


not sure if this will work or not (or at least not as easily)

pwm = new PWM((PWM.Pin)pin);

It is what I tried initially, but I couldn’t find a reference to the Spider board that supported PWM.Pin. Other non Gadgeteer FEZ mainboards were listed (Cobra, Mini, etc) but not Spider or Hydra.

Either way, I’m liking the Gadgeteer way.


Spider is actually EMX. You need EMX DLL.


@ jspy66

Right…that was my point exactly. The “new PWM” code is not intended for Gadgeteer, so you have to use the eBlockExpansion.SetupPWMOutput technique instead, where eBlockExpansion is the name of your eBlock Expansion instance. But actually playing tones is basically the same once you have the PWM instance.


gotcha - I didn’t know which DLL needed to be referenced.