Edbot

Support Template

Introduction

Scratch 2.0 is a visual programming language developed by the MIT Media Lab. It can be used for a range of educational purposes from maths and science projects to animated stories with art and music. It provides a stepping stone to the more advanced world of computer programming. Scratch 2.0 is available as an offline program. You can download a version for Windows & macOS from the MIT Web site. It is also available for the Raspberry Pi.

Getting started

The Edbot Play&Code kit enables you to assemble 6 different robots. The heart of the Edbot Play&Code is the CM-50 microcontroller - the yellow plastic box! The microcontroller has 4 built-in sensors (3 IR sensors and a clap counter), an internal buzzer and 2 motors. It has a holder for 3 x AA batteries and a socket for the Bluetooth (BT) module.

cm 50

The Edbot Software enables your Scratch 2.0 project to control your Edbot Play&Code robots by providing extra Scratch blocks in a Scratch 2.0 extension.

  1. Make sure the Edbot Software is running locally on your device. Your Edbot Play&Code robots should be available in the Robots pane. It doesn't matter if they are configured locally or remotely.

  2. Generate the sample projects by selecting Scratch → Generate Sample Projects in the Edbot Software. This will embed the Scratch 2.0 extension with your Edbot Play&Code names into each project. You can open any of the generated Scratch 2.0 projects but for now open the play_blank.sb2 project. You'll find the new blocks in the Scratch 'More Blocks' section. Note all Scratch 2.0 project files have an .sb2 suffix.

  3. After loading, your program will need control of the robot. Grant control using the active user menu in the Edbot Software. See below.

    edbotsw scratch2

If you're developing solo, the Edbot Software provides a convenient per-robot option "Bypass active user" in the Server → Setup → Configure window. This will allow any connection to control the robot. Check this option while developing so that you don't need to give control each time you test your program. To stop other network users inadvertently accessing the robot, uncheck the "Available on network" option.

Examples

Make sure you’ve generated the Scratch sample projects. See the Getting started section for details. We provide a sample project for each model.

car

play_car.sb2

Press the green flag and drive your car around obstacles using the on-screen arrows.

scorpion

play_scorpion.sb2

Place the scorpion on the black loop printed on the paper mat included with your kit. Click the green flag and watch it follow the loop.

puppy

play_puppy.sb2

Place the puppy inside the black loop printed on the paper mat included with your kit. Click the green flag and watch it stay in its pen.

windmill

play_windmill.sb2

Press the green flag to run. Adjust the the wind_speed slider control to make your windmill turn faster or slower.

bear

play_bear.sb2

Press the green flag to start the quiz. Click on the blue-bordered on-screen text box, type in your answer, and press the enter key. Bear doesn’t like to do pull ups, so make sure you get the answer right!

bird

play_bird.sb2

Press the green flag to start the script. Clap your hands twice to send your bird into a spin!

Use the Scratch → Project updater in the Edbot Software to rename robots in existing Scratch projects.

Next steps

The Edbot Play&Code Scratch blocks are described below in a fair amount of detail. Read through the rest of this document to get up to speed, there's a lot going on! We've called our Edbot Play&Code 'Anna', but you'll have given yours its own cool name of course…​

Some of the Edbot Play&Code Scratch blocks require you to enter a value. If you enter an invalid value, Scratch has no way of letting you know. You can check for errors by opening the Log Viewer window in the Edbot Software under Tools → Log viewer.

Motor blocks

Your Edbot Play&Code has 2 built-in motors on port 1 and port 2. You can control the motor speed and direction.

Single blocks

These blocks let you control an individual motor. If you need to control the motors simultaneously, use the multi blocks described below.

Set motor speed

block motor speed

This block controls the speed and direction of a motor on port 1 / port 2 of the microcontroller. The speed is entered as a percentage with 100 being full speed ahead. To stop a motor just set its speed to zero.

Multi blocks

These blocks allow you to control the motors simultaneously.

Set motor speeds

block motor speeds

Set the speed of the motors. Specify the port number followed by "/" followed by the speed expressed as a percentage. A negative speed will rotate CW, a positive speed will rotate in a CCW direction. Specify multiple motors by repeating the sequence, for example "1/50/2/50".

LED & buzzer blocks

Controller light

block controller light

The controller has built-in red and blue LEDs. Use this block to switch these LEDs on and off.

Buzzer pitch

block buzzer pitch

Use this block to play a note on the microcontroller's built-in buzzer. Specify the pitch, from 0 to 48 and the duration in units of 1/10 of a second (a duration of 10 would be 1 second).

Buzzer melody

block buzzer melody

This block plays a melody on the microcontroller's built-in buzzer. We use the term melody here loosely! A melody is represented by a number ranging form 0 to 24. You should allow a few seconds for the melody to complete. The following Scratch script cycles through each melody:

block buzzer melodies

Sensor blocks

Left IR sensor

block get left ir

The built-in left IR sensor uses infra-red to measure the distance to an object. It was calibrated using a vertical white A4 card. Note the sensor may give different measurements for different coloured objects placed the same distance away. The reading should be interpreted as an approximate distance in centimetres. The measuring range is 3cm to 20cm rounded to 1 decimal place. A value of 100.0cm means "out of range". In addition you can use the raw value returned from the sensor.

Right IR sensor

block get right ir

The built-in right IR sensor uses infra-red to measure the distance to an object. It was calibrated using a vertical white A4 card. Note the sensor may give different measurements for different coloured objects placed the same distance away. The reading should be interpreted as an approximate distance in centimetres. The measuring range is 3cm to 20cm rounded to 1 decimal place. A value of 100.0cm means "out of range". In addition you can use the raw value returned from the sensor.

Centre IR sensor

block get centre ir

The built-in centre IR sensor uses infra-red to measure the distance to an object. It was calibrated using a vertical white A4 card. Note the sensor may give different measurements for different coloured objects placed the same distance away. The reading should be interpreted as an approximate distance in centimetres. The measuring range is 3cm to 20cm rounded to 1 decimal place. A value of 100.0cm means "out of range". In addition you can use the raw value returned from the sensor.

Clap count

block get clap count

This reporter block detects the number of claps (loud noises) that have occurred in the last few seconds. This is called the live count. When you've finished clapping, the live count is transferred to the last count and the live count is set back to 0.

You can reset the last count to zero using the following block.

block clap count reset

Speech blocks

The following blocks instruct your Edbot Play&Code to speak! The voice, language, volume, pitch and speed will have been set up during configuration.

Try configuring your Edbot Play&Code with a different language, if you have the voices available. You can then type text in your chosen language in the speech blocks!

Say

block say

Say the words! This block won't wait for the speech to finish before continuing to the next block.

Say and wait

block say wait

Say the words! This block will wait for the speech to finish before continuing to the next block.

Current word

block get current word

This reporter block gives you the current word as it is being spoken. It returns empty text (zero length) if your Edbot Play&Code isn't speaking. Use it to add visual emphasis during speech. The example below displays the current word in a speech bubble.

block current word example

General blocks

Reset

block reset

Use this block to reset the microcontroller. It will stop any connected motors or servos, turn off the controller lights, set the last clap count back to 0 and halt any speech on a word boundary.

Status

block get status

This reporter block can be used to check if your Edbot Play&Code is connected to the Edbot Software and whether it is enabled or not. The block returns 1 if connected or enabled and 0 if not.