Start Create

Codecraft Online

More >
  • Cardboard for laser cutting (dimensions of at least 460*260mm, 2mm thickness, cutting template PDF available for download)
  • Rivets x 2, to connect the rainbow and the base
  • String or thin rope (min length 250mm, 2mm diameter for the swing)
  • Main board x 1, for programming
  • Photosensor - reacts to changes in light
  • Battery x 1, to supply electricity
  • servo x 1, Actuator to push candy out
  • some candy
  • mini toy or figurine, to add weight to help the weight swing, and be cute.




Step 3:Connect the rainbow with the base


We need cardboard pieces no.3 and 7, and two rivets. Fold piece 3 as demonstrated in the photo, paying careful attention to the direction of the folds.

Match up positions A and B on both segments No.3 and 7, using a rivet to fix in place.

P 3-3 shows what it will look like after this step.

Step 1  Gather Materials


Step 2 Coding and Testing


For an added challenge, with the explanation in the intro, you can code this program yourself without reading below, this way you will learn more than copying the following program provided.





Step 4: Build the candy bin

Gather cardboard segments No.1,2 and 6, according to the steps in the following photos, connect pieces 1,2,3, 6 and 7 together. Carefully examine photos for indication of direction and positioning (especially No. 1, 2 and 3) .

P4-4 is how the Rainbow Swing should look after step 4.

Step 5: Attach the swing

For this step we need the piece of rope or string and cardboard piece no.4. Copy the method shown in the picture.

When cutting the pieces of string, be careful to make sure the lengths are as similar as possible after tying the knots. Tip: Leave extra length on the string, which you can cut off later. Ask your parents or friends for help if you need to.

P5-5 shows the product after step 5 - the protoype is taking shape!







Step 6: Assemble the base

Firstly, we make sure the cutouts are cut through. The three cutouts on the section that will be twisted under should be folded so that they stick out upwards, with the remaining cut outs also folded so they stick up, this will prevent the candy from rolling out.

Then we will follow P6-2 to fold the base, and connect it with the previous assembly.



Step 7: Install the switch

Take the servo and cardboard No.5, unplugging the control wire from the servo's base board. Attach as shown in P7-2.



Step 8: Install Grove Zero modules


Fingers can be inserted in the cutout holes to adjust the positioning of the modules. If your hand isn't big enough, just put the modules in first and adjust the position of the modules one by one.




Step 9: Insert candies and decorate


The previous step completed the functionality of the rainbow swing. Here I've used a hot glue gun to fix a little white rabbit which will add some weight to help the swing wobble.




Careful adjustment of light intensity is the key to making the rainbow swing work well. The light intensity will depend on the range and direction of light where the swing is set up.

This will need to be adjusted in the software program.

We can connect a four digit display to help us easily compare the values of light intensity when the swing is moved, and ultimately decide what light intensity value is most appropriate to actuate the servo.

Codecraft 2.X
Codecraft User Manual
G0 module introduction


20 min

When you lightly swing the swing, a piece of candy pops out. How magical is that!?  Actually once you understand how this works, you can make one too. When the swing wobbles, the light sensor underneath senses a change, which controls the servo motor. The servo turns and out pops the candy.  Follow these steps to make your own!

Rainbow Swing


Back to Home >