Skip to main content

Mini-project: CodeBugs and codeclub

Taken from post in

Playing with the CodeBug

Codebug is great fun, the Blockly programming is more challenging than Scratch but that is ok. 

As a test a Codebug was used to control two glowbugs (see for more details on Glowbugs and working with them on the Codebug). 



  Set the  Glowbugs 0 and 1 to yellow;
  Scroll a message across the 5x5 grid saying yellow;
  if button A is pressed
    Set the Glowbugs 0 and 1 to red;
    Scroll a message across the 5x5 saying red;
  if button B is pressed
    Set the Glowbug 0 to blue;
    Scroll a message across the 5x5 saying blue;  

Driving a small motor
A simple transistor circuit is used here to get the CodeBug to control a small motor, turning it on or off.
Drawn using Schemeit (

The motor used here was a small cell-phone vibration motor, but it has been tried with other small motors.

Using ‘leg 1’ to switch the motor on or off, +5v comes from the CodeBug PWR connector and GND come from the CodeBug. It can only drive the motor in one direction.

In the code below Button A switches on the motor and Button B switches the motor off.


These little devices provide something different to a code. To see the coding interface go to (or see figures 1 and 2) and click on create.

Last two weeks
Week 1 
The code clubbers initially shared machines, playing with the CodeBug environment, practice downloading to the bug, writing a routine to scroll their short message. The challenge was then to develop a routine to have a smiley face and a grumpy face scroll across the screen.

Week 2
All have access to the simulation and code generation on but this time they don’t have the CodeBug each, they have complete a challenge and run it on the simulation before get a CodeBug to try it. This week's challenge was to get the smiley and grumpy face from week 1 to be selected via the buttons (A and B) - so it involved a loop and conditional statements. Most of them picked it up very quickly.

Two version were built - I reconstructed the ideas in figures 1 and 2 (the code clubbers often did a better version than mine shown here!).

Figure 1: Simple Scroll
The one shown in Figure 1 works by pressing A -scrolls :-) and B - scrolls :-( . Some spotted that the the 'nose' wasn't quite in the place. Some went and found the build sprite block and used that instead.
Figure 2 - Using the build sprite.

Lessons learnt
  • Give them all access individually to the CodeBug website but not to the physical CodeBug straight away
    • They are often a limited resources
    • There is a great temptation from the code clubbers to focus on download to the actual device when the seem to get more done if the spend more time with website and its simulator first;
    • When they have something interesting to put on the ‘bug’; then they can borrow a bug and try it out.
  • They should do a bit of a show and tell.

Related posts

Basic Motor Control using CodeBug
messing around with Codebug

All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with.If you'd like to find out more about Computing at the University of Northampton go to:

Popular posts from this blog

Experiments in teaching Neural Networks

Excel Based

More details available at including links to the code.

All views and opinions are the author's and do not necessarily reflected those of any organisation they are associated with. Twitter: @scottturneruon

Social Analysis of Publications

The Computing staff's network of co-authors, at the University of Northampton, based on the University's  research repository NECTAR - on 12th November 2016. The data goes back to 2010.

The data was analysed using the software VOSviewer - free software for visualising networks. Differences in colours represents, the clusters of publications with those authors picked out by the software. The relative size of the circles is the relative number of publications listed; so for the two biggest circles/hubs it relates to 55 and 34 publications in this time period. Some relatively new authors, to the University but not to research, explains some of the 'islands' and the number of publications within it - it only reflects publications whilst at the University of Northampton.

To dig a little deeper, going to  look at the two biggest 'hubs' through their NECTAR records, so potentially going …

Computer lecturer’s research helps improve the next generation of technology

Taken from: A computing lecturer at the University of Northampton, who is researching into how the efficiency of our everyday devices, such as mobile phones, can be improved, has been awarded the best paper at two recent conferences. Dr Michael Opoku Agyeman has written several journal papers focusing on how the next generation of technology can meet the ever increasing demands from consumers. He was invited to present his work at the 19th Euromicro Conference on Digital System Design in Cyprus and the Institute of Electrical and Electronics Engineers’ 14th International Conference in Paris. Part of his research concentrates on whether several processing elements can be incorporated on a single chip, known as System-On-Chip, to improve the efficiency and speed of the computing systems that we use every day, from mobile phones to video-game consoles and even medical equipment…