Friday, 19 February 2016

Ozobot Coding with OzoBlockly


Ozobot is a mini robot that can be programmed with OzoBlockly, a graphical drag and drop language. My kids have been working on a LEGO town for their OzoBots.

OzoBlockly supports line-following and colour reading behaviour and allow you to control the robot's movement and RGB LED light.

In this article we'll look at the OzoBlockly code that we used to program Ozobot with custom behaviour for the town.

OzoBot in Action

You can find out more in our Ozobot in LEGO town post, but here's the video that demonstrates Ozobot's behaviour as it follows the path and reads stickers to perform actions.


Using OzoBlockly

OzoBlockly runs in a web browser and offers drag and drop coding. OzoBlockly offers different levels of coding for different abilities starting with icon-based coding that can be used by kids who can't read yet. 

You can mix and match blocks from different levels so my kids were able to use some of the preprogrammed light sequences (rainbow and fireworks) within a more complex program. 

You can also program the lights by choosing precise colours and adding in delays. My 9 year old had specific requirements for the 'harbour' behaviour so that was directly coded. 

Ozobot's behaviour is a bit different to the robots my kids have programmed before so they needed some help figuring out how to get the behaviour they wanted. We worked together to understand things for the first time and then they could extend the code once the framework was in place.  

We like that you can mix up the line-following behaviour and the programmed movement within a single program.


Line Reading Behaviour

Out of the box, Ozobot is a line following robot that reads colour code commands. The line-following behaviour can still be accessed in custom coding mode. 

You can tell Ozobot to continue until the next intersection or line end. At intersections Ozobot will choose a random direction. 

The code for my kids LEGO town started really simply. Just using the line following capability to wander around the town choosing a random path at intersections.

Basic wandering code
The line colour changes at an intersection as Ozobot decides which way to go. Other behaviours could be added here in future.

If a line end is found (a dead end) then Ozobot turns round and carries on its journey.

Line End Colour Detection

When Ozobot reaches the end of a path it can check for a colour. We've used this feature by adding small coloured stickers at the end of paths to tell Ozobot what to do. 

This project is a work in progress but at the moment a blue path end sticker indicates an Ozobot home. Ozobot will turn its light blue and take a rest when it finds a home.

A blue sticker at the end of a line indicates a home


When Ozobot finds a red sticker that indicates a special behaviour. As well as line-following behaviour Ozobot's movement can be directly programmed. This capability is used to move forward and then read the colour of the sticker that is found.




A red sticker indicates a light show - Ozobot will do a light display. This feature is used under a translucent brick structure. Ozobot drives under a crystal dome and lights it up.

A blue sticker indicates a waiting spot such as the harbour. Ozobot alternates between blue and green lights while it waits.




A green sticker indicates a trick - Ozobot will charge forward and push or knock over an obstacle and then do a firework light display to celebrate.


Other behaviours can be added later using this approach. 

Loading OzoBlockly Programs

OzoBlockly is available as a web app. It can be used from PCs and tablets. Saving projects only works on PCs at the moment though. Saving is to a downloaded file rather than to a cloud-based account. 

For a longer term project like this it's important to be able to save work so we've used a PC although a tablet would have been more convenient for working close to the board. (We'd love to see saving to an account in future so it's easy to access previous projects.)

You load code onto an Ozobot by placing it onto the computer screen which displays a sequence of colours. The longer your code is the longer this takes. 

With this project we would go through a few iterations of coding and uploading and then the boys would play with their Ozobots and explore the new feature they had added. 

What Next?

The play board still has plenty of blank space. The boys are planning more LEGO structures and paths for Ozobot to navigate. They can reuse the behaviours that are already programmed by adding coloured stickers. And they have the option to add more code too.




More from Tech Age Kids:

Comments:

Post a Comment