Make a Fidget/Gyro-Keychain With Code Using Tinkercad Codeblocks

3,257

30

8

Introduction: Make a Fidget/Gyro-Keychain With Code Using Tinkercad Codeblocks

About: I am a teacher who sometimes makes videos.

This is a lesson walking through the steps of creating a spinning gyro keychain using the tools available through Tinkercad codeblocks. The codeblocks allow Tinkercad users another method for developing shapes, and it is a fairly powerful tool. The keychain is pretty fun to play with, and this is a great entry point for people interested in the intersection of coding and 3d printing.

Start with this video overview:

A note on this guide. Make sure to both read the steps AND view the images. It will make the instructions much easier to follow. Also, I would have preferred to have made the code simpler, but the current version of the codeblocks has some limitations. It would have been nice to have been able to use if statements and functions among other things(would have cut the number of lines of code needed in half).

Supplies

A computer/chromebook

3d printer (optional)

Step 1: Create a New Tinkercad Codeblocks Project

Go to Tinkercad.com and log into Tinkercad account, and select "Codeblocks" from the toolbar on the left. Then select "Create New Codeblock."

A new window will pop up. In the new window, select "New Design"

Step 2: Set Up Parameters

Now that we have created our file, we are going to set up parameters that will allow us to code more easily, as well as to make whatever adjustments we want once the code is finished. The best practice for creating parameters is to name them as you create them. If you try to drag them all out and then name them, you will probably accidentally make them all the same.

Drag the green "Create Variable" block onto your screen, and click the tab to rename it "Number of Rings". Change the zero to a 3. We will use this parameter to control how many rings our keychain has (although 3 is really ideal, any more or less it doesn't really work as well)

After you have finished, create the rest of the parameters and initial values as listed below. In the image, you can see I added comments, they are notes to help readers understand the codeblocks, you can add some of your own, or you can leave them out.

Create the remaining parameters:

ring width 3

height 4

ring gap 2

1st Ring Width 1.25

Inner Radius 11.75

rotation 0

Step 3: Set Up Calculations

We now need to do a little math with our parameters. These calculations are essential to simplifying the remaining code, and making the keychain parametric, allowing you to adjust the parameters to get a different outcome.

I have simplified them all to 2 step calculations, in order to try to simplify them. Order of operations matters to some of these, so be careful! If things aren't working right later, this is probably where the mistake is, so you can come back here and make sure your equations are correct.

We will be creating more variables to store the results of these calculations, so drag out a new variable block (make sure these are below your initial parameters), and change its name to "ring size difference". Then drag out the green math block that says "0 + 0", and place it where the value would have gone for this parameter. Under the data section drag the blue block that says "ring gap" to replace one of the 0's, and drag the blue block that says "ring width" to replace the other zero.

Add a second variable, and rename to "combined rings". This is where we need to be careful. This is a two step calculation and we want to make sure it works with order of operations. Here is what we want: "Ring Size Difference" * ("number of rings" - 1). We have to make sure the part in the parenthesis gets done first. The way we do that is by nesting that calculation into the other one. So first make a math block that subtracts "number of rings" - 1. You can change the '+' to '-' by clicking the '+'. Then take another math block, and change the '+' to '*' and put ring size difference into the first zero, and place your subtraction block you just made into the other zero. (There is a lot of steps here, look at the picture to help understand it).

Make the following remaining variables, and set them equal to the calculations shown.

"outer radius" = "combined rings" + "1st ring width" + "inner radius"

"current width" = "outer radius"

"cone height" = "ring gap" + 1.4

Step 4: Create the Pegs/cones That the Rings Spin On

Now that we have completed all the upfront work, we can begin to create our gyro keychain. The first thing we are going to do is to create a shape that we will use for the cones that the rings spin on.

  1. From the modify menu, select the block "Create New Object" and rename it as "pegs"
  2. Add a cone shape to the pegs object, and select the white arrow to expand your options
    • Set the top radius to 0.3
    • Set the bottom radius to the calculation: "height/2"
    • Set the "H" to "cone height"
    • make sure the filled in option is selected
  3. Select the move option from the modify menu, and put the calculation "cone height"/2 into the z direction
  4. Add a solid cylinder, with a radius of "cone height"/2 and a height of 1.
  5. add a move block with a distance -.05 for Z
  6. add a group block (you can select the color if you want when you do this)
  7. add a rotate block, select "x axis" and '-90' for the degrees. Drag the "X:0 Y:0 Z:0" block from the math menu and put it for the pivot

Now the peg is complete and we are ready for the next step. Run the simulation to make sure it looks ok. You can see mine with the pictures above.

Step 5: Create the Cone Shaped Holes for the Pegs to Spin In

No we are going to make another new object (below the first one) that will allow us to make holes for the cones to spin in.

  1. Create a new object and rename it as holes.
  2. Add a cone to it, and change the top radius to 0.35
    • Change the bottom radius to ("height"/2)+0.75 -> make sure to nest the part in parentheses into the other math block
    • Change H to "cone height "+ 0.1
  3. Add a "move" block, and for Z input the following calculation ("cone height" +0.2)/2 -> make sure the part in parentheses nests into the other math block.
  4. Add a "group" block, and for this one select to make it a hole instead of solid.
  5. add a "rotate" block, select "x axis" and '-90' for the degrees. Drag the "X:0 Y:0 Z:0" block from the math menu and put it for the pivot

Now the hole is complete and we are ready for the next step. Run the simulation to make sure it looks ok. You can see mine with the pictures above.

Step 6: Keychain - Outer Ring

Now we will start making the keychain with the outer ring first. We will be inputing all the parameters we worked so hard to set up at the beginning, which will allow us to easily make adjustments to the keychain when it is all done. We will be making the first ring, and adding the holes where the pegs will spin.

  1. Make a new object below the last one, and rename it to "gyro keychain"
  2. Add a "tube" shape, and set the following parameters:
    • set radius to "outer radius"
    • set Wall Thickness to "ring width"
    • set H to "height"
  3. Add a set item block and change "item" to "current width". For the amount put "outer width" - "ring size difference". The block should say: set "current width" to "outer width" - "ring size difference"
  4. Add a "repeat" block and change the number of times to 2.
  5. Inside the "repeat" block choose an "add copy of object" block, and drag the "holes" variable into the block. Make sure you click to choose make it a hole instead of a solid.
  6. Add a move block next (still inside the repeat block), and put "current width" for the y direction
  7. Add a rotate block (still inside the repeat block)
    • Set the axis to z
    • Drag the "rotation" parameter in to set the amount
    • and drag the 0,0,0 block in for the pivot
  8. Add a change item block, and change "item" to "rotation," and set the amount to 180. (still inside the repeat block)
  9. (Add these ones below the "repeat" block) Add a set item block, and change "item" to rotation and put zero as the amount.
  10. Add a "create group" block below the "repeat" block, make sure to select to make it a solid.

Now we have finished the outer ring. It should have two holes in it, and it is ready to add all the inner rings. Run the simulation to make sure it looks ok. You can see mine with the pictures above.

Step 7: Middle Rings Part 1

We are going to start the middle rings, and this will make any where from zero to as many rings as you want depending on what you select as the number of rings. When it is set as three, there is just one inner ring. Each of these rings has pegs on the outside and holes on the inside. We will add the blocks here to the end of the blocks we just finished.

  1. Add a count with i block to the previous blocks, and change the from amount to 2 and the to amount to "number of rings"-1
  2. Add another tube (inside the count with block)
    • set radius to "current width"
    • set wall thickness to "ring width"
    • set h to height
  3. Now we will add the pegs: Add a repeat block and set the number of times to 2. (inside the count with block)
  4. Inside the "repeat" block choose an "add copy of object" block, and drag the "pegs" variable into the block.
  5. Add a move block next (still inside the repeat block), and put "current width" for the y direction
  6. Add a rotate block (still inside the repeat block). Set the axis to z, the amount to "rotation", and the pivot as 0,0,0.
  7. Add a change item block, and change "item" to "rotation," and set the amount to 180. (still inside the repeat block)
  8. (Add these ones below the "repeat" block, but still inside the count block) Add a "create group" block below the "repeat" block, make sure to select to make it a solid. - I set the color for it, so you can see they are all one piece.
  9. Add a change item block, and change "item" to rotation and put 90 as the amount.
  10. Add a set item block
    • change "item" to "current width"
    • add the following calculation "current width" - ("ring gap" + "ring width"). Make sure to nest the part with the parenthesis inside of the other calculation

Now we have finished adding the pegs to the inner rings. The next step will be to add the holes to these rings. Run the simulation to make sure it looks ok. You can see mine with the pictures above.

Step 8: Middle Rings Part 2

We will continue from where we left off in the last step to add the holes on the middle rings.

  1. Add a repeat block and set the number of times to 2.
  2. Add copy of object "holes" and make sure to select that it will be a hole.
  3. Add a move block and move it "current width" in the y direction. (still inside the repeat block)
  4. Add a rotate block (still inside the repeat block). Set the axis to z, the amount to "rotation", and the pivot as 0,0,0.
  5. Add a change item block, and change "item" to "rotation," and set the amount to 180. (still inside the repeat block)
  6. Outside the repeat block, but still inside the count block, add the group block, making sure it is selected as solid.

We have finished the middle rings! This will make as many rings as you need, so if you change the total number of rings to 100, this will make 98 of them! (the most rings I got it to do was 18, because Tinkercad limits the size of the rings) Next we will be finishing it with the inner ring. Run the simulation to make sure it looks ok. You can see mine with the pictures above.

Step 9: Inner Ring

We now will make the inner ring. For this one, we want pegs, but no holes on the inside. You will attach a design/logo/text to this ring later.

  1. Add one last tube. (below the count with block)
    • set radius to "current width"
    • set wall thickness to "1st ring width"
    • set h to height
  2. Add a repeat block and set the number of times to 2.
  3. Inside the "repeat" block choose an "add copy of object" block, and drag the "pegs" variable into the block.
  4. Add a move block next (still inside the repeat block), and put "current width" for the y direction
  5. Add a rotate block (still inside the repeat block). Set the axis to z, the amount to "rotation", and the pivot as 0,0,0.
  6. Add a change item block, and change "item" to "rotation," and set the amount to 180. (still inside the repeat block)
  7. Add a "create group" block below the "repeat" block, make sure to select to make it a solid. - I set the color for it, so you can see they are all one piece.

Now the inner ring is done. There are just a few finishing touches before we have completed our shape. Run the simulation to make sure it looks ok. You can see mine with the pictures above.

Step 10: Finishing Touches + Create Part

Now we just have to delete the cones in the middle, and we can export our blank gyro keychain.

  1. Add a delete object block and drag the "pegs" variable into it.
  2. Add a delete object block and drag the "holes" variable into it.
  3. Add a move block and move it "height"/2 in the z direction (this is so that it is sitting on top of the work plane)
  4. Run the simulation to make sure it looks ok. You can see mine with the pictures above.
  5. Click export
    • Select part
    • name your part
    • Save it!

Now we have created a tinkercad part. Next we will add something to our blank keychain and add a key ring before exporting it to 3d print.

Step 11: Add Something to the Middle of Your Gyro Keychain

We are going to add a shape to our keychain. When we are done adding it, we need to make sure it is sized to fit within the ring, and has a height of 4mm or less. There are a number of different options for how to add something.

Click 3d designs, and select new design.

Options:

  1. Make your own shape, or add text
  2. Use the scribble tool to draw something to go in the middle
  3. Go to thingiverse.com and look up a logo or shape

Now that you have something to put in the middle, let's go ahead and do it.

  1. Choose part collection, and drag your
  2. Resize your shape (hole down the shift key and drag a corner to scale it uniformly)
  3. Select both the keychain and your shape, and select the align tool. Click the center dot in the bottom and on the side to center them
  4. Adjust the position and size of the shape so that it fits within the center ring, but overlaps it, which will ensure it is attached when you print it.
  5. Adjust height of the center piece so that it is 4mm tall.
  6. When you are happy with the positioning, Select your shape and the gyro keychain, and select to group them.

Step 12: Add a Key Ring + Export

Now we will create the ring on top so that we have a keychain.

  1. Create a tube with a wall thickness of 1.5 and a radius of 5
  2. Add a box, and resize to 10x10, set it to be a hole, rotate it 45 degrees
  3. Center it on the tube and move it so it overlaps only the bottom half. Group them together. Resize the height to 4mm.
  4. Center the keyring on the keychain, and move so that it overlaps the outer ring. Group them together.

The keychain is complete! Now you just have to export it.

  1. Select Export from the top right toolbar
  2. Select .stl from the menu

Now you can 3d print your keychain. How you do this is up to you. For my students, we will 3D print and mail them for those who complete the assignment. The settings shouldn't matter too much, unless your printer is out of calibration. I print them with 0.3mm layer height to speed them up and it works great. If you have trouble with that, you can reduce the layer height and see how it works. If it doesn't spin well after playing with it for a few min, it may also be worthwhile scaling the model up 1-2% to increase the size of the gaps between the parts.

Step 13: Examples

I will update this step with samples of student work as they are turned in. Here are some of the ones I a have received so far. My 3d printer is out of commission, but once it is repaired, I am printing and mailing these to my students. I will update with photos of printed keychains.

Thank you for reading this Instructable. If you are interested in future projects, please subscribe to my Youtube channel More Than The Sum

Distance Learning with Tinkercad Contest

First Prize in the
Distance Learning with Tinkercad Contest

Be the First to Share

    Recommendations

    • DIY Summer Camp Contest

      DIY Summer Camp Contest
    • Summer Fun: Student Design Challenge

      Summer Fun: Student Design Challenge
    • Water Speed Challenge

      Water Speed Challenge

    8 Comments

    0
    mizzw
    mizzw

    9 months ago

    Do you have any other suggestions for improving the spin? I'm printing at a similar layer height and also tried scaling it up 2% but the pegs still don't really spin well in the holes. I have to break them to get them to move and it just kind of destroys the peg ends. I'm newer to 3D printing and using a Lulzbot Taz 6. Any other tips you have would be greatly appreciated.

    0
    More Than the Sum
    More Than the Sum

    Reply 9 months ago

    On the slicer side, you could try reducing the print temperature or the flow rate. On the design/code side, in the places where you add the gaps, you could try increasing the size of those gaps.

    0
    PixelNinja132
    PixelNinja132

    1 year ago

    Very good! Great tutorial, how I can print this soon!

    2
    Penolopy Bulnick
    Penolopy Bulnick

    1 year ago

    This is really neat and it's fun to see how you came up with the design!

    Do you happen to have a link to the Tinkercad design for tinkering?

    0
    Charles Projects
    Charles Projects

    Reply 1 year ago

    Hi Penolopy, turnout today I see in youtube, there is a good tutorial by Eunny, on how making this project.
    Here is the link: https://www.youtube.com/watch?v=4nS_VUye7x4

    Maybe it is a little different, but the principle is almost similar. I hope it helps.

    0
    More Than the Sum
    More Than the Sum

    Reply 1 year ago

    Hi, thanks! The goal with this project is to provide a lesson on using codeblocks, so I don't know that I want to share the completed one for now.