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.

Jaime Florence's Content

There have been 3 items by Jaime Florence (Search limited from 06-July 23)


By content type

See this member's

Sort by                Order  

#39395 New to this : Trouble with AnalogInput with Firmware v4.2.0.1

Posted by Jaime Florence on 15 November 2012 - 03:01 AM in Netduino 2 (and Netduino 1)

Bingo.

NooM and Baqs, you were both right. I ended up using pot.ReadRaw() and AnalogChannels.ANALOG_PIN_A0.


Thanks again for the help! Now I can continue on, and I know more about AnalogChannels, debugging in C# and using MS VC#.



For anyone else that has this, here is the what I used to make the potentiometer on the MakerShield work with the little blinky app:

            OutputPort led = new OutputPort(Pins.GPIO_PIN_D0, false);
            AnalogInput pot = new AnalogInput(AnalogChannels.ANALOG_PIN_A0);

            int potValue = 0;

            while (true)
            {
                //read the value of the potentiometer
                potValue = (int)pot.ReadRaw();
                Debug.Print("ReadRaw analog value: " + pot.ReadRaw());

                // blink the LED based on the pot's value (0-1023ms)
                led.Write(true); // turn on the LED
                Thread.Sleep(potValue); // sleep based on the Pot
                led.Write(false); // turn off the LED
                Thread.Sleep(potValue); // sleep based on the Pot

            }
Sincerely,

Jaime



#39361 New to this : Trouble with AnalogInput with Firmware v4.2.0.1

Posted by Jaime Florence on 14 November 2012 - 06:35 PM in Netduino 2 (and Netduino 1)

Awesome. Thanks for the help! I'll try the RawRead and/or pot.Read() * 3.3f. Also I'll use Debug.Print to see what I'm getting. I'll post back and let you know how it goes. Thanks, Jaime



#39322 New to this : Trouble with AnalogInput with Firmware v4.2.0.1

Posted by Jaime Florence on 14 November 2012 - 02:55 AM in Netduino 2 (and Netduino 1)

Hi,

Let me apologize in advance for what is probably a silly question or mistake on my part. I'm brand new at most of this and I'm a bit lost. I did try to do some searching on this forum in hopes of finding my own answers, but most of the topics are way beyond what I'm working on. I'm literally just trying to build the equivelant of "hello world" type stuff and already stuck.

I just recieved my Netduino and begam working through the Getting Started with NetDuino documentation. I noticed that the Netduino had an old Firmware so I went trhough the steps of flashing it and installing the newer SDKs. I built the first Blinky app with the Netduino and all was well.

I built the MakerShild and began making the Blinky app work with that (the LED and button). This worked well too.

Once I started trying to write the code to read the (analog) values from the potentiometer on the MakerShield I started getting debugger errors within MS Visual C# Express.

AnalogInput pot = new AnalogInput(Pins.GPIO_PIN_A0);
I get : "Error 1 The best overloaded method match for 'Microsoft.SPOT.Hardware.AnalogInput.AnalogInput(Microsoft.SPOT.Hardware.Cpu.AnalogChannel)' has some invalid arguments C:\Users\Jaime\documents\visual studio 2010\Projects\Blinky\Blinky\Program.cs 18 31 Blinky"


I noticed that there was a mention of "2. New core AnalogInput and PWM classes; backwards-compatible classes available via add-on assemblies". Does this mean that I need to include something more to be able to use the Pins.GPIO_PIN_A0 above?

I hacked around and was able to get the following to compile:
AnalogInput pot = new AnalogInput(AnalogChannels.ANALOG_PIN_A0)
but that doesn't seem to recieve any values from the potentiometer.

The source is attached.


Any tips would be greatly apreciated.

Thanks,

Jaime

Attached Files





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.