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

Simple Motor Project *Completed


  • Please log in to reply
11 replies to this topic

#1 CwbhX

CwbhX

    Advanced Member

  • Members
  • PipPipPip
  • 85 posts
  • LocationNYC

Posted 11 November 2010 - 01:40 AM

After lots of help from the community and my friend I have finished my project :) of controlling a motor with the Netduino(Project 1). The motor and on board LED turn on when the on board button is pressed.
Here is a video of it, and the code which follows.
http://youtu.be/wneXYjR5GEY?hd=1
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;

namespace NetduinoApplication1
{
    public class Program
    {
        static InterruptPort button;
        static PWM motor = new PWM(Pins.GPIO_PIN_D6);
        static OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);

        public static void Main()
        {
            // write your code here
            button = new InterruptPort(Pins.ONBOARD_SW1, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth);

            button.OnInterrupt += new NativeEventHandler(button_OnInterrupt);

            Thread.Sleep(Timeout.Infinite);

        }

        static void button_OnInterrupt(uint data1, uint data2, DateTime time)
        {
            led.Write(data2 == 0);
            if (data2 == 0)
            {
                motor.SetDutyCycle(100);
            }
            else
            {
                motor.SetDutyCycle(0);
            }

        }

    }
}

Here is the diagram Posted Image

I would also like to thanks Chris, Oz, CW2, Denver(Not a member), and Bill.French.


Sincerely,
Cwbh



EDIT: Schematic (Sorry, my first time?): Posted Image
-Cwbh

#2 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 11 November 2010 - 02:08 AM

After lots of help from the community and my friend I have finished my project :) of controlling a motor with the Netduino(Project 1). The motor and on board LED turn on when the on board button is pressed.
Here is a video of it, and the code which follows.

...

Sincerely,
Cwbh


Not sure why you're thanking me, but you're welcome...? Anyways I loved it, it looks great and very well documented! Keep up the great work.

#3 CwbhX

CwbhX

    Advanced Member

  • Members
  • PipPipPip
  • 85 posts
  • LocationNYC

Posted 11 November 2010 - 02:18 AM

Not sure why you're thanking me, but you're welcome...? Anyways I loved it, it looks great and very well documented! Keep up the great work.


Well, you pretty much gave me the idea. You inspired me with some of your code, and tutorials. :D
Hmm... Now on to Project 2.

This should also come in handy when I get back to my elevator project...

-Cwbh
-Cwbh

#4 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 11 November 2010 - 02:53 AM

Well, you pretty much gave me the idea. You inspired me with some of your code, and tutorials. :D
Hmm... Now on to Project 2.

This should also come in handy when I get back to my elevator project...

-Cwbh


Sounds great, I'm looking forward to it. Good luck and if you have any questions, I'll try my best to help you.

#5 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 11 November 2010 - 07:17 AM

Congratulations! Nicely done. Tip: You can use different duty cycle values to control the speed of the motor, e.g. SetDutyCycle(50) will run it at about half speed. For a simple on/off switch (no speed control), OutputPort.Write(true/false) will also work.

#6 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 11 November 2010 - 03:44 PM

CwbhX. That's great! Good to see that you figured it all out and have it up and running. Looking forward to seeing project 2... Chris

#7 CwbhX

CwbhX

    Advanced Member

  • Members
  • PipPipPip
  • 85 posts
  • LocationNYC

Posted 11 November 2010 - 08:59 PM

Thanks guys! I will be posting a schematic soon for a better picture... -Cwbh
-Cwbh

#8 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 12 November 2010 - 02:01 AM

Thanks guys! I will be posting a schematic soon for a better picture...

-Cwbh


The schematic isn't bad, but you can do it easier and with pre-made parts with Fritzing - http://fritzing.org/

Hope that helps

#9 CwbhX

CwbhX

    Advanced Member

  • Members
  • PipPipPip
  • 85 posts
  • LocationNYC

Posted 12 November 2010 - 03:42 AM

Thanks so much Oz! I was wondering how in your videos it seems so perfect :P Have a good night -Cwbh
-Cwbh

#10 Omar (OZ)

Omar (OZ)

    Advanced Member

  • Members
  • PipPipPip
  • 564 posts

Posted 12 November 2010 - 04:33 AM

Thanks so much Oz! I was wondering how in your videos it seems so perfect :P
Have a good night

-Cwbh


Glad to help, thanks for the complement :) .... you can call me Omar, I just use "OZ" because its easier to type.

#11 Philip

Philip

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationPreston, England

Posted 16 November 2010 - 10:22 AM

Hi All, I'm developing a motor control for a small mobile robot. It uses the DFRobot Arduino Compatible Motor Shield , which has a motor driver chip on it that will interface directly to the PWM pins. This was very easy to set up, and gives me variable speed as well as reverse. I drive it from a wired serial connection (soon to be Xbee) from a PC. The PC application is also written in c# and consists of a couple of sliders to control the speed of the right and left motors. When it's done I'll post it as a project.

#12 CwbhX

CwbhX

    Advanced Member

  • Members
  • PipPipPip
  • 85 posts
  • LocationNYC

Posted 16 November 2010 - 12:33 PM

Wow! Thats pretty impressive Philip. I will be awaiting to see it in the project section :D -Cwbh P.S. I don't know is I posted this in this thread, but I also have that shield; my weak C# skills won't allow me to program it yet.
-Cwbh




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.