- Getting started
- Next steps
- Motor blocks
- LED & buzzer blocks
- Sensor blocks
- Speech blocks
- General blocks
Scratch 3.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 3.0 is an online Web app that runs in your browser.
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.
The Edbot Software enables your Scratch 3.0 project to control your Edbot Play&Code robots by providing extra Scratch blocks in a Scratch 3.0 extension. The MIT team haven't yet announced how they plan to incorporate external Scratch 3.0 extensions into their main Web site. However they've made the source code of Scratch 3.0 available on GitHub which has allowed us to add our own extensions!
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.
Use the following link to access Scratch 3.0 with the Edbot Play&Code extension:
Most modern browsers should work. Add the Edbot Play&Code extension by clicking the extensions button in the bottom left corner and selecting the Edbot Play&Code extension. This will load the Edbot Play&Code blocks.
After loading the extension, your program will need control of the robot. Grant control using the active user menu in the Edbot Software. See below.
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.
You can open the sample Scratch 3.0 projects too. We provide a sample project for each model.
First generate the sample projects by selecting Scratch → Generate Sample Projects in the Edbot Software. This will embed the Edbot Play&Code Scratch 3.0 extension into each project. Select File → Load from your computer from the Scratch 3.0 menu and select the project you'd like to open. Note all Scratch 3.0 project files have an .sb3 suffix.
Press the green flag and drive your car around obstacles using the on-screen arrows.
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.
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.
Press the green flag to run. Adjust the the wind_speed slider control to make your windmill turn faster or slower.
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!
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. You may need to reload the Scratch 3.0 Web page to get the updated Edbot Play&Code extension.
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.
Your Edbot Play&Code has 2 built-in motors on port 1 and port 2. You can control the motor speed and direction.
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
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.
These blocks allow you to control the motors simultaneously.
Set 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
The controller has built-in red and blue LEDs. Use this block to switch these LEDs on and off.
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).
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:
Left IR sensor
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
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
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.
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.
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 the words! This block won't wait for the speech to finish before continuing to the next block.
Say and wait
Say the words! This block will wait for the speech to finish before continuing to the next block.
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.
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.
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 true if connected or enabled and false if not.