Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

ricafort

Member Since 08 Mar 2013
Offline Last Active Mar 17 2013 11:15 PM
-----

Posts I've Made

In Topic: Anyone have a good PWM example for Netduino Plus 2?

13 March 2013 - 11:05 AM

I got it working now using the solution below:

 

[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]"If you're using AnalogInput, add the SecretLabs.NETMF.Hardware.AnalogInput.dll assembly as a reference to your project. If you're using PWM, add the SecretLabs.NETMF.Hardware.PWM.dll assembly as a reference to your project."[/color]

 

http://forums.netdui...uino-2/?p=47140


In Topic: Getting Started with Netduino 2

13 March 2013 - 11:02 AM

Thanks very much, I finally made it working by following your advise:

 

[color=rgb(40,40,40);font-family:helvetica, arial, sans-serif;]"If you're using AnalogInput, add the SecretLabs.NETMF.Hardware.AnalogInput.dll assembly as a reference to your project. If you're using PWM, add the SecretLabs.NETMF.Hardware.PWM.dll assembly as a reference to your project."[/color]


In Topic: Anyone have a good PWM example for Netduino Plus 2?

13 March 2013 - 09:20 AM

I cannot find setpulse() function on netduino 2. how can I run the code below in netduino 2?

 

Making Music example

 

public static void Main()
{
// write your code here
// store the notes on the music scale and their associated pulse lengths
System.Collections.Hashtable scale = new System.Collections.Hashtable();
// low octave
scale.Add("c", 1915u);
scale.Add("d", 1700u);
scale.Add("e", 1519u);
scale.Add("f", 1432u);
scale.Add("g", 1275u);
scale.Add("a", 1136u);
scale.Add("b", 1014u);
// high octave
scale.Add("C", 956u);
scale.Add("D", 851u);
scale.Add("E", 758u);
// silence ("hold note")
scale.Add("h", 0u);
int beatsPerMinute = 90;
int beatTimeInMilliseconds =
60000 / beatsPerMinute; // 60,000 milliseconds per minute
int pauseTimeInMilliseconds = (int)(beatTimeInMilliseconds * 0.1);
// define the song (letter of note followed by length of note)
string song = "C1C1C1g1a1a1g2E1E1D1D1C2";
// define the speaker
PWM speaker = new PWM(Pins.GPIO_PIN_D5);
// interpret and play the song
for (int i = 0; i < song.Length; i += 2)
{
// extract each note and its length in beats
string note = song.Substring(i, 1);
int beatCount = int.Parse(song.Substring(i + 1, 1));
// look up the note duration (in microseconds)
uint noteDuration = (uint)scale[note];
// play the note for the desired number of beats
speaker.SetPulse(noteDuration * 2, noteDuration);
Thread.Sleep(
beatTimeInMilliseconds * beatCount - pauseTimeInMilliseconds);
// pause for 1/10th of a beat in between every note.
speaker.SetDutyCycle(0);
Thread.Sleep(pauseTimeInMilliseconds);
}
Thread.Sleep(Timeout.Infinite);
}

In Topic: Getting Started with Netduino 2

13 March 2013 - 12:56 AM

Thanks very much Chris. I will try them out and will update this post :)


home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.