Introduction: Code a Charm Bracelet
CREATOR(S): Diane Brancazio and Anya Timchenko, MIT Edgerton Center
Create and 3D Print Articulated Charm Bracelets
Design and 3D print your own articulated charm bracelet, of any length! “Articulated” means that you print the entire piece at once, and when you remove it from the build plate the pieces are hinged together - no assembly required! Use Codeblocks, the Autodesk coding environment in Tinkercad to create a charm and a link, then multiply it to any size. Add open connector links to make your chain into a bracelet or to connect several chains. Create these charm chains using a simple coding platform. Learn basic coding principles and see how they can be useful in designing objects with repetitive features.
How can coding be used in design to make standard parts and repeating shapes?
What are the basic principles of coding and how are they useful in design?
- 3D modeling of features in articulated objects
- Basic coding principles
- Coordinate planes with X, Y, Z axes
Time Required: 1 - 2 Hours
- Codeblocks workspace in Tinkercad
- 3D printer and filament
Step 1: Understand the Project and Explore Codeblocks
3D modeling and 3D printing are already fun, engaging, hi-tech activities. One of the coolest features of 3D printing technology is that objects can be created with interior voids that cannot be fabricated using traditional methods. A fascinating application of that capability is the creation of articulated objects that have hinged parts and are moveable right off the build plate.
In this activity, designers use geometric and mathematical concepts and experiment with “ChainCoding” - generating code for the charm bracelets/chains based on the example code in this tutorial. Designers choose the number of charms in the chain. The only constraint is the size of the print bed on the 3D printer.
As 3D modeling and printing technologies become more reliable, less expensive, and easier for beginners to use, they become useful tools for practicing other skills such as coding, math, and logic. This activity is based on Tinkercad Codeblocks where users “design with code” - making 3D models using draggable blocks of code.
Features of Codeblocks:
- There are computation blocks for common math functions including: ( ) + - * /.
- Objects can be moved around the design space on standard X, Y, Z axes, and can be scaled along those axes as well.
- Designers can create and set variables for objects and for mathematical quantities and can call them in the math computation blocks.
- Count and Repeat loops are available for replicating objects easily
- All the usual Tinkercad 3D modeling capability of building with primitive shapes that can be solid or holes, and grouping to create new shapes.
The first step is to get familiar with the block-based programming environment in Tinkercad Codeblocks. Watch the Quick Start Guide on the Codeblocks site to learn how to snap and unsnap blocks. Explore and practice with these investigations:
1. The Workplane and the Origin
a. The Workplane measures 200 mm x 200 mm. The Origin is the center point where X = 0, Y = 0, and Z = 0
b. Objects come into the Workplane with their center points on the Origin. To set objects to specific positions, it is necessary to shift them in the X, Y, and Z directions. A convenient way to do that is to move the object by half its size in the X, Y, and or Z direction. Some objects allow you to set those Width, Length, and Height dimensions when they are created, others you can determine by moving them around.
a. Pick a Shape. Click and drag it into the black workspace.
b. Find the “Move” function. Click and drag it into the code space until it attaches to the Shape:
c. Play around with the X, Y and Z values individually.
- At what position do all shapes start when imported?
- What happens when you make a value negative?
a. Some Shapes will have an extended size arrow that imports the Shape with that specified size. Import and play around with the options to see how the object changes.
b. Locate and import the “Scale” function into the code space.
c. Attach the “Scale” to the Shape and play around with changing the X, Y and Z variables.
a. Import a new Shape or use an existing Shape.
b. Find and add the “Rotate around” function to the Shape.
c. Rotate the Shapes around the X, Y and Z directions, switching the degree variable each time.
d. Try adding multiple rotations to the same shape.
Does the direction change the second/third the time you rotate?
a. Import two or more shapes.
b. Add a “Move”, “Rotate” or “Scale” one of them.
c. Turn one of the shapes into a hole.
d. Find the “Create group” function, add it to the shapes.
e. Group the shapes as followed:
- Solid grouped to solid. Overall shape: Solid.
- Solid grouped to a hole. Overall shape: Solid.
6. Define variable
a. Import the “Create Variable” into the code space.
b. In the drop-down options, select “Rename Variable…” and rename as “Number pieces”. In the number box on the right, change the variable to anything between 1 and 10. (This number will be a reference for the repeat variable to refer to.)
c . Find and attach a “Count with” to the bottom of the “Create Variable”. The variable “i” is the index number used in the Count loop
d. Under “Data” find the “Number pieces”, and drag the code into the “10” box.
e. Import a “Shape”, a “Move”, and a computation block “0 + 0” found under “Math” into the code space. Change the + to any of the drop-down selection (+,-,*,/) and choose a number to move the shape by in the second number variable box. You can play the “0+0” blocks inside each other and play around with the math to see how the equation affects the X, Y, and Z movement.
Here is an example of a math equation placed in the Y variable:
((5 + i) * number pieces)) The i stands for the “Count with” number variable and the number pieces references the number found in the “Count Variable”.
f. Add the “Shape” and “Move” code into “Count with” and play the code.
g. Play around with the numbers under “Move”, and “Create Variable”. Try changing the 1 in “count with”, to see how it affects the code.
7. Repeat variable.
a. Find and import the “Repeat” function.
b. Add two or more “Set Color”.
c. Play around with the colors and see if you can make a glowing pattern.
You should now be comfortable enough with Codeblocks to easily follow the activity instructions. Have fun!
Step 2: Design a Charm
Create this code in your workspace to make a basic charm with a star design. Use the Create New Object block to give it a name and let you copy the entire object later.
The Charm is a flat circle, radius 15 mm, or diameter 30 mm. At the end of this tutorial you will see how to swap out this code and create charms of other shapes.
Step 3: Add the Cutouts and Pins for the Hinges
Step 4: Create Link to Next Charm
Create a new object and call it “Link”. This hole in this link is concentric with the pins on the charm. The pins are 1.1 mm radius, while the hole in the link is 1.5 mm radius, resulting a diameter. That results in a 0.4mm clearance between the pin and the link. When fabricated on a 3D printer, the pieces will not bond together, and will move freely when they are removed from the build plate.
Step 5: Create a Chain
Now it’s time to create a chain. Use the Count loop to multiply the charms and the links by any number. Create a variable (as explained in Step 1 exploratory exercises) called “number charms”. Set the variable to your chosen number. You will add additional charms to the original one you created, so the count loop goes from 1 to “number charms-1”. There will be 1 more charm than link, so the count loop for the links goes to “number charms -2”. The Move applies to the entire body since the new section is added to it.
The code described above can be found at https://www.tinkercad.com/codeblocks/jnjPmnjD3Hu
Step 6: Create a Closed Link to Connect the Loose Ends
Use this code to create the link in Codeblocks. The same part is shared in Tinkercad here https://www.tinkercad.com/things/hzEC77j8yPK. There are 2 parts included, 1 locked and 1 scalable.
Step 7: Export the Part and 3D Print It
Step 8: Project Extensions
Create a new Charm shape! As long as the cutouts and pins for the charm are attached to the shape you create, the rest of the code will work to create a chain.
Try this code to make an open heart chain. Note the use of scale blocks to get the right size (done by trial and error) and the need for a Y move by -0.5 to center the object where the original round object was.
Thanks for trying our Instructable!
We hope you had fun designing and sharing your charm chains. What did you make? We want to see! If you did this in a K-12 classroom, what subject was it in?
Send us an email or leave us a comment so we can see what you're making.
Visit our website k12maker.mit.edu to get resources for K-12 teachers:
- Maker skills workshops for K-12 educators - Spring, Summer, and Fall.
- Makerspace Design Guide for K-12 Makerspaces.
- Lists of Tools and Materials and illustrated charts to print and post.
- Supervision and safety guidelines for shop administrators.
- Training guides for common tools (including student checklists and refresher guides).
- Our Maker Methodology for designing Maker Projects for core curriculum, including sample projects.