Back to Activity
Tutorial
Colour Tails Introduction
{% trans 'Sorry, your browser does not support canvas -- please either update your browser or submit your requirements by phone or email.' %}

Accelerometer

Loading Blockly...

Step 1 /8

Introduction

When writing programs for your Colour Tail, it is useful to see what your program will look like, using the emulator. You can add your Colour Tail to the emulator in a few steps:

  • Click on the cog at the top right of CodeBug.

  • Under the Connected Hardware title, tick the CodeBug Colour Tail box.

  • Tick the check-circle for the Colour Tail you are using.

  • Click Apply button.

Step 2 /8

Setting a Colour Tail pixel

To control the LEDs on Colour Tail you need to use the blocks from the Colour Tail menu.

  • Click the Colour Tail menu.

  • Drag in a set colour pixel to colour block and snap it to the start block.

  • Set the colour by clicking on the coloured square and pick the colour you want from the window that appears.

Step 3 /8

Run your code

Click the Play button to run your code. The LED 0 on the Colour Tail emulator image will change to the colour you set.

Step 4 /8

Loop through the LEDs

To cycle a pattern on your Colour Tail, you need to change the colour of each LED in sequence.

  • From the Loops menu, drag in a count with block and snap it to your start block.

  • Drag your set colour pixel to colour block into your count with block.

  • From the Basics menu, drag in a pause block and snap it beneath your set colour pixel to colour block (making sure it is inside your count with block.

  • Drag the 0 block from inside your set colour pixel to colour block, into the bin.

  • From the Variables menu, drag in the i block, and snap it into the new gap in your set colour pixel to colour block.

  • Click on the second number block (after the text ‘to’) of your count with block and set it to one less than the number of LEDs on your Colour Tail.

Step 5 /8

Run your code

Click the Play button to run your code. The LEDs will turn on one by one.

Step 6 /8

Repeating patterns

To create a repeating pattern you will need to change the LEDs between two colours.

  • Right-click your count with block and click Duplicate and snap this copy below your original count with block.

  • Click on the colour of your second colour pixel to colour block and change it to a different colour.

  • From the Loops menu drag in a repeat while true block and snap it to your start block.

  • Drag the rest of your code into this repeat while true block.

  • Click on the your pause blocks and change them to 200.

Step 7 /8

Run your code

Click the Play button to run your code to watch your repeating pattern continuously change.

Step 8 /8

Download your code

Click the Download button to download your program, then follow the instructions to load it onto your bug.