Skip to main content

Arduino Lesson : Using a DC motor



Hey guys, today we will be using the arduino to control a motor!

to wire this just use this drawing I made in fritzing:


  Unfortunately, these kinds of motors do not have an adapter that will allow you to connect it to the arduino, so I had to solder two jumper cables on each of those little metal things that come out of the motor and connect one to ground and the other to pin 6. This code will make that motor start spinning:

void setup() {

pinMode (6, OUTPUT);

}

void loop() {

digitalWrite (6, HIGH);

}

Now upload this sketch to your arduino and the motor should start spinning. Which direction does it spin? now try swapping the cables, which way does it spin now? With most motors, it should be spinning in the opposite direction! If you have any problems do not forget to comment them!


please follow me on this blog, and on twitter @axtyab, and hopefully refer this blog to others that you know!



Comments

Popular posts from this blog

1. Blinking LED

Blinking LED: HI, Axtyax here! Now that you have gotten your arduino and IDE, you are ready to start exploring the world of arduino! Things You Will Need Solderless Breadboard (if you dont know what this is, look it up) Wires An arduino The arduino cable to connect it to your computer A computer with the arduino IDE  Im not completely sure, but i think you will need an 820ohm 1/8w resistor (if you know of better specs for the resistor, just comment please) And finally, an LED.  This is a visual representation of how to wire up your circuit that i made in an application called fritzing, which you should definitely download from this link to create schematics for any of your arduino projects. Ok so now that you have wired up the arduino and resistor and LED, lets get started on the code! This is the code: ----------------------------------------------------------------------------------------- /*   Blink   Turns on an...

Intro to C++ and Hello World

Hey guys, axtyax here! and today we will be beginning c++! C++ is probably the most powerful programming language out there, and is constantly updated! Some of the uses of c++ are Video games Commercial applications, for math or even analytics Mobile applications microcontrollers such as the arduino and much much more  So now that we have a basic understanding on why c++ is an optimal language, lets get started! *WARNING c++ is not simple, but with some practice, you can make so many on your computer that you will regret not having starter c++ sooner! So when we start out our program we need to declare all of the libraries we will be using. think of libraries like a group of many tools for c++ that are made to be utilized by the user, without any libraries, displaying simple text on the screen would be VERY difficult. right now, though, the only library we will use is call iostream iostream just creates the stream of input and output from the console windo...