Welcome to my tutorial on how to build a rotating table. I hope you enjoy the process. It very easy to do and you get to test some light sensors and other components out as well.

Step 1: Intro and Getting Started

This project dispalys describes a simple and quick design for a rotating table that anyone from hardware beginners (such as I) to experienced hardwarers can recreate. It is a great way to learn something new, rehash simple skills or just create a rotating table, something you need, with ease. I am only using Adafruit products so if you have any questions about any other hardwares I cannot answer them.

The items you will need are:

  1. A Arduino Uno R3 (with Atamega328 assembled) LINK TO PRODUCT
  2. A 5 volt power supply for Arduino Uno R3 LINK TO PRODUCT
  3. Some sort of platform to rotate (I use a cheap pizza pan for weight reasons)
  4. A part with flat top to attach to bottom of platform (3d print or get creative)
  5. Lots of male to male wires. (You can never have enough plus you can strip the heads off for end to end connection purposes.) LINK TO PRODUCT
  6. A Steppper Motor, specifically a NEMA-17 size , 200 step, 12 volt 350mA Stepper Motor. LINK TO PRODUCT
  7. Stacking headers for R3 and Motor Shield (Should come with Motor Shield. If not they are very inexpensive)
  8. Adafruit Motor Shield for Arduino version 2.3 (which is the latest version) LINK TO PRODUCT
  9. 12 volt power supply for motor shield (Because Arduino power will not be enough) LINK TO PRODUCT
  10. A 12x12 Photobox (you can get any size you want) LINK TO PRODUCT
  11. Mini Bread Boards LINK TO PRODUCT
  12. Light Sensors (Optional if you do not want to go this far) LINK TO PRODUCT

WARNING BEFORE YOU START:For this to work you must solder the stacking pins to the R3 and solder the header pins to the Motor Shield. R3 needs this connection to send signals to the Motor Shield. If you have not soldered the pins on do so now.

Here is a youtube video explanation for assembling a Motor Shield:

Here is a STL file you can use for your project if you have a 3d printer available. If you want to modify the design the files are also below. You will need to install sketchup and an extension called "Sketchup STL" for exporting STL files for Makerbot 3d printers.

Step 2: Connecting the Power Supply

Now you have the stackers soldered onto both the Arduino Uno R3 and Motor Shield, lets connect the power supply to the Motor Shield. We do not have to worry about the Arduino Uno R3 for it should have a separate power supply via USB or 5 volt power supply.

  1. Cut both heads off the wires with a wire stripper and leave a small length of copper on both sides to insert into the power supply and adaptor. (Twist the copper together to make to easier to insert into power supply adaptor and power supply terminal)
  2. Insert each of the copper wires into the appropriate slot (positive to positive and negative to negative) and tighten the screws that clamp down on the copper part of the wires. (The screws for the motor shield are smaller than the standard tool heads. You need to get creative to screw and unscrew them)

Now whenever you are ready to power the motor shield you can just plug the power supply into the adaptor.

Step 3: Connecting the Stepper Motor

If you have Motor Shield connected to Arduino Uno R3, you do not have to separate them for this step.

Do the same thing you did for step 2.2. But this time follow the specific pattern in the image above. Connect the object you will attach to the bottom of the platform to the stepper motor to test if your setup works.

You will need to download Arduino, the library for the stepper motor. Import the library into Arduino then include it into your code.

WARNING: Do not use supplied stepper motor library named "Stepper" under Examples. That is for version 1.0 stepper motors. Use the library you downloaded and imported to make stepper motor run.

The image after is how your work should look so far. Here is a video it in action using the code below:

Code is located below for your test. Feel free to edit this code any way you need to.

Step 4: Testing Light Sensors (Breadboard Time)

Next you have to test the light sensors to map out the pins you will use for light detection. I used the digital outputs for this step but feel free to to use the Analog outputs. For the digital outputs the code is located below. You can modify the code to work with Analog outputs.

WARNING: You also need to separate the Motor Shield from the Arduino Uno R3. The Analog pins and Digital pins are all occupied by the Motor Shield which makes it near impossible to insert other components. Although, to re-allow access to these pins you must solder the extra stacking headers onto the Motor Shield in the appropriate places. If you have already soldered the extra stacking headers onto the Motor Shield you do not have to separate the Motor Shield from the Arduino Uno R3.

For this step, I used different color wires, 4 light sensors and digital pins 2,3,6, and 7. The power source is the Arduino Uno R3 and I use both 5v and 3.3v pins to send power to the light sensors. In the custom written library posted below, I used set each light sensor to the associated angle on the unit circle: 0, 90, 180, 270 (0 is 360). That way I can simulate selected angles the platform will rotate based on the time the electric signals take to get to the Arduino Uno R3. To see the results of the setup you just need to cover one of the light sensors and it will show you the time it takes for each sensor to send electric signals back.

Before we continue we need to know the difference between Digital/IO pins vs Analog pins from this LINK.

Now we have some understanding of Digital/IO pins and Analog pins, lets create the light sensor test.

To test your light sensors you need to:

  1. Establish a connection to your power source(s) (Which in this case is the 3.3v and 5v pins on the Arduino Uno R3)
  2. Connect the power sources to one spot on the edge of the breadboard.
  3. Insert light sensors. The one closest to the power source will not have a spot in between while the second farthest light sensor will be a spot gap wide. This is to give each light sensor it own channel since one channel returns one result.
  4. Connect those wires to the Digital or Analog pins you want to work with. Make sure to change the pin numbers in the code to the pins you use. You may have to change the method used to access the pins (digitalRead() to analogRead() and digitalWrite() to analogWrite() if you use analog pins).
    • You may need to change the method RCTime() to suit your needs if necessary.
  5. Upload code to Arduino Uno R3. Open the Serial Monitor and view the output.You should see something similar to the output on the video if you used the Digital/IO pins.

Step 5: Combining Light Sensor and Stepper Motor Operations

Now lets combine the light sensor reading and stepper motor rotation into one operation. In this step, I do not have the headers soldered due to lack of access to a soldering machine. However, signals sent through the motor shield are still strong enough to get some sort of input back. The code below is an example of both operations combined.

The code step by step:

  1. The current angle is stored as a previous angle.
  2. We get the angle of the light sensor that takes the longest to send back a signal.
  3. Check if the new current angle is greater than or equal to 0. If it does not meet this condition, reset the current angle to its previous value and do nothing.
  4. Get the difference of the new current angle and the previous angle.
  5. Compare the difference. Only possible values are -270, -180, -90, 0, 90, 180, 270.
    • move forward 90: 90, -270 (from 270 to 0)
    • move backward 90: -90, 270 (from 0 to 270)
    • move forward 180: 180
    • move backward 180: -180
  6. Rotate to light sensor selected position (These are stats for a 200 step motor rotation conversion to degrees. There are 1.8 degrees per step.)
    • move forward 90: (50 x 1.8) = 90, FORWARD (clockwise)
    • move backward 90: (50 x 1.8) = 90, BACKWARD (counter-clockwise)

    • move forward 90: (100 x 1.8) = 180, FORWARD (clockwise)

    • move backward 90: (100 x 1.8) = 180, BACKWARD (counter-clockwise)

The commented out code is an example of the different types of steps you can use for your project. It was from the previous stepper motor code posted on this Instructable.

The video shows the light sensors and stepper motor working together in harmony.

Step 6: Final Step: Personal Design

This step is optional. Therefore, you can stop at step 5 and have this function via breadboard and power sources only or outfit it with containers and platforms.

For this final step, you just decide how to design the platform and component container. Details such as "Should I insert the light sensors on the top of or on the sides of the box?" or maybe "Should I attach the stepper motor to the box top or not?"

This step is totally free of constraints for customization purposes. That way you can personalize it based on your curiosity or for your needs.

Thank you for following this tutorial. Have a wonderful Thanksgiving/Christmas and never lose the fire of curiosity!

<p>Cool idea</p>

About This Instructable




More by MichaelM320:Rotating Table Tutorial 
Add instructable to: