Waving Codebug

Introduction

Give CodeBug moving arms and legs using servos – small electric motors.

Jumper cables come in three main types as shown below. This activity assumes your servos have female sockets to connect to, and therefore we will use male to male jumper cables (but you can use male to female cables if your servo has male pins).

A servo is a precise motor that can rotate a certain number of degrees (usually 180°). Servos are great for making robot arms, cranes or even robots.

You will need
CodeBug CodeBug
Servo motor
Jumper cables
OR Card
Thick paper
Scissors
Single-sided tape
Printer

Wiring up the servo

You may need to check the information sheet of your servo, however they usually have three wires. The brown wire is negative (GND), red is positive (PWR) and orange is data input.

Plug in one male to male jumper wire into each hole in your servo’s socket. Plug the jumper connected to the brown wire into the socket labeled GND on CodeBug’s expansion port. Plug the jumper connected to the red wire into the socket labeled VCC on CodeBug’s expansion port. Finally plug the jumper connected to the orange wire into the socket labeled SDO on CodeBug’s expansion port.


Writing your program

We need to set up one of CodeBug’s legs as a servo controller and move it back and forth. Follow the tutorial below to write your code.


Testing your servo

Plug the single beam connector onto your servo, this is what we will stick the arm to. Download your project onto your CodeBug and give it a spin! Your servo’s shaft should spin one way and then the opposite way again and again.


Creating your arm

Once you are sure your servo is waving properly, stick the servo to the back of your CodeBug, with the shaft facing forwards.

Print these arm templates on thick paper or thin card and carefully cut out your favourite arm (making sure it is the left arm). Attach the arm to the plastic arm connector on your servo with some sticky tape. Plug in your CodeBug and wave hello, for the first time ever CodeBug will wave back!


What next

Take a video of your waving CodeBug and share it with us on Twitter.

You could add three more servos to give CodeBug another waving arm and two waggling legs from the print out. When using more than two servos, you will need to connect them up to a separate power supply.

Have a go as designing your own arms and legs for CodeBug and Tweet us the pictures.


Back to top