Introduction: R5-D4 Model

This model of R5-D4 consists of 3 blue LEDs as its eyes and a step motor to turn its head. The LEDs blink in a certain pattern that shows “R5D4” in Morse code: di-dah-dit di-di-di-di-dit dah-di-dit di-di-di-di-dah. For “di” and “dit”, an LED light blinks for 0.5 sec; for “dah”, an LED blinks for 1.5 sec. Between the letters and numbers of R, 5, D, and 4, all LEDs turns off for 1 sec. The step motor is used for the 180 degrees left and right movement of R5-D4’s head. The target audiences of this R5-D4 model are kids, particularly Star-Wars fans.This R5-D4 model can inspire kids to be interested in AI technology, robotics, Arduino, and programming languages, which are the future technology chain. Since R2-D2, C-3PO, and BB-8 are Star Wars robots commonly made into models, an R5-D4 model also allows a Star-Wars fan to collect a more complete selection of Star-Wars droid characters.

Step 1: Supplies


- 1 Arduino Leonardo (click here!)

- 1 Mini Breadboard (click here!)

- 3 LEDs (Blue) (click here!)

- 3 Resistors (10k ohm) (click here!)

- Step Motor (click here!)

- Step Motor Driver Board (click here!)

- Female-Male Jumper Wires (click here!)

- Male-Male Jumper Wires (click here!)

R5-D4 Model:

- 1 Can with Lid

- 1 Paper Bowl with a Similar Diameter to the Can

- 1 White Foam Board (10mm, 20x30cm) (click here!)

- Markers (Orange, Blue, Grey, Black)

- 2 A4 Paper

- 1 Railroad Board (click here!)

- Double-sided Tape

- Scotch Adhesive Putty

Step 2: LEDs

After preparing all the supplies, the second step would be connecting the LEDs to the mini breadboard and the Arduino Leonardo board. As the circuit diagram shown above, connect the female-male jumper wires (the 3 pairs of red and black wires) to the LEDs. The female-male jumper wires here are to extend the length of the LEDs, since the whole circuit would be hid inside the can and the LEDs would be placed on R5-D4’s head. When you're ready to with the LEDs, place the 10k ohm resistors and male-male jumper wires on the breadboard and from the breadboard to the Arduino Leonardo board. Each LED should be connected to a 10k ohm resistor. The LEDs in this circuit are connected to digital pin 11, 12, and 13. The LED connected to digital pin 11 is the LED 1; the LED connected to digital pin 12 is the LED 2; The LED connected to digital pin 13 is the LED 3.

Step 3: Step Motor

After setting up the LEDs, the third step would be connecting the step motor to Arduino and the breadboard. Arrange the female-male jumper wires, male-male jumper wires, step motor, and step motor driver board like the circuit diagram shown above. The step motor driver board in this circuit is connected to digital pins from 2-5. Note that the purple, dark blue, light blue, and yellow wires in the circuit are female-male jumper wires, while the red and black wires are male-male jumper wires. Bear in mind that the purple wire is connected to digital pin 2; the dark blue wire is connected to digital pin 3; the light blue wire is connected to digital pin 4; the yellow wire is connected to digital pin 5.

Step 4: Code

After you are finished with the circuit, you can start writing the code!


Line 28 - 32: shows that LED 1, 2, and 3 are connected to digital pin 11, 12, and 13 respectively.

Line 34 - 54: shows the pattern of LED blink, di-dah-dit di-di-di-di-dit dah-di-dit di-di-di-di-dah, where di-dah-dit is R, di-di-di-di-dit is 5, dah-di-dit is D, and di-di-di-di-dah is 4 in Morse Code. An LED light turns on for 0.5s at "di" and "dit", an LED light turns on for 1.5s at "dah", all LED lights turn off for 0.5s at "-", and all LED lights turn off for 1s at " ". For each letter and number (R, 5, D, 4), the LED lights shine in the order of LED 1, LED 2, LED 3, LED 1, LED 2, so on and so forth. When one letter or number's code is finished, then it starts from LED 1 again for the next letter or number.

Line 55 - 61: shows the code of the step motor. If you would like to change how many degrees your R5-D4 model's head turns, you may adjust the number representing the number of steps each electricity pulse turns the motor. A full 360 degrees circle corresponds to the number 512. Here, I made the number 256, meaning the head does a 180 degrees turn. 10 in line 55 and 60 represents the speed of the motor. The smaller the number, the faster the motor's speed. However, do not put in a number smaller than 4! The numbers of 2, 3, 4, and 5 in line 55 and 60 refer to the corresponding digital pins your motor has connected with.

Line 64 - 109: shows the coding for each LED's blinking. a(), b(), c(), d(), e(), and pause() are customized functions. a() is the code for LED 1 to blink "di" and "dit"; b() is the code for LED 2 to blink "di" and "dit"; c() is the code for LED 3 to blink "di" and "dit"; d() is the code for LED 1 to blink "dah"; e() is the code for LED 2 to blink "dah"; pause() is the code for all LEDs to turn off for 0.5s.

Step 5: R5-D4 Model

After you finish testing the circuit and code, you can start making the R5-D4 model, which includes the head, body, and two legs. To make the model, you would need the supplies listed in the supply list. For all supplies, you can change the sizes according to your own preference.

1. Draw the patterns of R5-D4’s head and body, each on a piece of A4 paper, like picture (1) and (2) shown above. If you’ve changed the size of the can and the paper bowl, the sizes of the pattern may change accordingly. You may photo copy the R5-D4 body pattern you’ve drawn with a printer twice, since you would need two of them for the front and back of your R5-D4 model.

2. Stick the patterns of the body and head you've drawn on the can and the paper bowl as shown in picture (3) and (4).

3. Cut out the legs of R5-D4 with a piece of white foam board. The dimensions of the leg parts are shown in picture (5). After cutting the shapes out, stick the rectangular part on the irregular shaped part and draw a blue rectangle on each like picture (6).

4. Assemble the circuit with the model. Make 3 holes on the head you’ve made to place the 3 LED lights. Then, put the circuit inside the can like picture (7). You can put the circuit in a box first, then put in the can to prevent it from moving around. Remember to make a hole underneath the can to allow the USB cable stretch out.

5. Cut out an oval-like shape from the railroad board, make a hole at the center, attach it to the step motor, and use tape, or any other mean to stick it onto the can as shown in picture (8).

6. Make a hole on the lid of the can that is big enough for the motor shaft to pass through. Attach the plastic gear-like plate with the can lid by any mean. Here, I used needle and thread as there are holes on the plastic plate. Then, make the shaft pass through the hole on the plastic plate like picture (9).

7. Put the LEDs into the holes you have made in step 4. You may use adhesive putty to prevent the LEDs from falling (refer to picture (10)). When you are finished positioning the LEDs, you may put the lid and the head together.

8. Lastly, use double-sided tape to stick the legs onto the body. Then, you are finished! The final product should look like picture (11).

Step 6: How Does This Work?

If you're using Arduino Web editor, you can refer to the link attached below, which is a YouTube video that guides you step-by-step through the process of activating the website and uploading the code to your Arduino device.


(Note that the board I used here is Arduino Leonardo, but in the video, he uses Arduino/Genuino Uno. Remember to select the board you used!)

No matter if you're using Arduino Web editor or the Arduino software, after you have plugged in the USB cable and clicked upload like the pictures shown above, your R5-D4 model would start blinking "R5D4" and turn its head!