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.
Photo

Question - Getting Started with Netduino Chapter 6

Dimmer PWM Run Led

Best Answer CoryP, 09 November 2013 - 02:25 PM

I seriously overlooked the fact that the LED was not wired properly based on my code.  My code was referencing Pin D5 and I had the LED wired for D0. Thanks for the guidance. Much appreciated.

Go to the full post


  • Please log in to reply
4 replies to this topic

#1 CoryP

CoryP

    New Member

  • Members
  • Pip
  • 3 posts

Posted 08 November 2013 - 02:51 AM

Hello all. I have a question about the dimmer project in chapter 6 of Getting Started with Netduino.

 

When I run my code it is deployed successfully yet when I turn the potentiometer there is no change in the intensity of the led. I've checked my code, set my deployment target correctly, selected the correct Target framework to no avail. Am I overlooking something? Any guidance would be greatly appreciated.

 

Hardware: Netduino Plus 

Framework: .Net Micro Framework 4.2

 

Code: 

 

using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
 
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino; 
 
namespace Dimmer
{
    public class Program
    {
        public static void Main()
        {
SecretLabs.NETMF.Hardware.PWM led = SecretLabs.NETMF.Hardware.PWM(Pins.GPIO_PIN_D5);
SecretLabs.NETMF.Hardware.AnalogInput pot = new   SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A0);
 
            pot.SetRange(0, 100);
            int potValue = 0;
 
            while (true)
            {
                potValue = pot.Read();
                led.SetDutyCycle((uint) potValue);
            }
 
        }
 
    }
}
 


#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 08 November 2013 - 03:57 AM

Hi CoryP, Can you add a quick line after "potValue = pot.Read();" and see what values you're getting? Either the potentiometer isn't wired properly, the LED isn't wired properly, or there's something odd going on that we need to dig into :)
Debug.Print("potValue: " + potValue.ToString());
Thanks for picking up my book! And welcome to the Netduino community, Chris

#3 CoryP

CoryP

    New Member

  • Members
  • Pip
  • 3 posts

Posted 09 November 2013 - 02:34 AM

Thanks for the response Chris!

I added the line to my code and I see the values changing in my output tab in Visual Studio. 

What's weird though is if I deploy the project from Chapter 5 where the potentiometer controls a blinking LED everything works fine and turning the knob changes the rate of blinking.



#4 CoryP

CoryP

    New Member

  • Members
  • Pip
  • 3 posts

Posted 09 November 2013 - 02:25 PM   Best Answer

I seriously overlooked the fact that the LED was not wired properly based on my code.  My code was referencing Pin D5 and I had the LED wired for D0. Thanks for the guidance. Much appreciated.



#5 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 09 November 2013 - 06:10 PM

No worries, Cory. This is one of the reasons why we love Visual Studio so much: it's easy to debug these things. P.S. I think that we've all wired things up to the wrong place at least once before. That can be part of the fun of the journey. Welcome to the Netduino community, Chris





Also tagged with one or more of these keywords: Dimmer, PWM, Run, Led

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.