Back to Activity
Tutorial
GlowBugs
{% 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 Colour Tails and GlowBugs, it is useful to see what your program will do before you load it onto your CodeBug. You can do this with the emulator. To add your GlowBugs to the emulator, follow these 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 GlowBugs x 5.

  • Click Apply button.

Step 2 /8

Setting a GlowBug pixel colour

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 tail pixel to colour block and snap it to the start block.

  • Set the colour by clicking on the coloured square on the block 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 GlowBugs emulator image will change to the colour you set.

Step 4 /8

Flash the LED

To flash the LED we need to turn it on and off, with a pause in between.

  • From the Basics menu drag in a pause block and snap it beneath your set colour tail pixel to colour block.

  • From the Colour Tail menu drag in another set colour tail pixel to colour block and snap it beneath your pause block. Set this new block to a different colour.

Step 5 /8

Run your code

Click the Play button to run your code. Notice that LED 0 changes colour.

Step 6 /8

Continuous flashing

To flash your LED more than once, you need to replay or ‘loop’ your code.

  • From the Loops menu, drag in a repeat while true block and place it on a blank area on your workspace.

  • Click on your first set colour tail pixel to colour block and drag your blocks into your new while loop.

  • Snap your while loop onto the start block.

  • From the Basics menu, snap in another pause block below your second set colour tail pixel to colour block (making sure it is inside the repeat while block).

Step 7 /8

Run your code

Click the Play button to run your code. LED 0 on the GlowBugs emulator will change colour continuously.

Step 8 /8

Download your code

Click the Download button to download your program. Make sure to follow the download to CodeBug tutorial to load your program onto your bug.