Upload
others
View
5
Download
0
Embed Size (px)
Citation preview
SCRATCH BUILDER
RQ ROBOT CODING GU IDE
W W W . R O B O B U I L D E R . N E T
Scratch is developed by the Lifelong Kindergarten Group at
the MIT Media Lab. See http://scratch.mit.edu1
1. How to install ScratchScratch and Scratch Builder need to be installed in the user’s computer to control RQ robots
with Scratch.
>Scratch?: Coding program made by MIT Medial Lab.
>Scratch Builder?: Program that helps connecting the robot and Scratch.
1) Go to the Scratch website (www.scratch.mit.edu/)
2) Move down to the bottom of the website
3) Select Offline Editor from Support.
SCRATCH BUILDER 2
01 INSTRALLATION AND SET-UP
4) Install Adobe AIR and Scratch Offline Editor in order.
① ②
SCRATCH BUILDER 3
Scratch has been
installed. Shall we
install the next
program?
2. How to install Scratch Builder1) Go to the Robobuilder website (www.robobuilder.net).
2) Select SOFTWARE under SUPPORTS.
3) Download the Scratch Builder software from SOFTWARE and install.
4) Run ‘Setup.exe’ file.
(If this message “User Account Control-Do you want to allow this app from an
unknown publisher to make changes to your device?” appears, click Yes to continue
with the installation).
5) Select ‘English’
6) Click ‘Next’.
SCRATCH BUILDER 4
SCRATCH BUILDER 5
7) On License Agreement, click ‘I Agree’.
8) Check the destination folder and click ‘Install’.
9) When RQ-USB2UART Driver appears during installation, click ‘Next’.
SCRATCH BUILDER 6
10) On License Agreement (RQ-USB2UART Drive-related), Check ‘I accept…’ and click ‘Next’.
11) Once the RQ-USB2UART Driver Installation has been completed, Click ‘Finish’. Continue with
remaining Scratch Builder installation.
12) Scratch Builder has been installed. Click ‘Finish’.
SCRATCH BUILDER 7
13) The Scratch Builder screen opens.
The program has
been installed. Now,
let’s learn how to
connect the robot
with the computer!
3. How to connect the USB2UART cable when directly connecting to RQ controller.To have Scratch communication with the RQ robot, it needs to be connected with the
communication cable (RQ-USB2UART).
(If it does not work even when the communication cable is normal, try reinstalling the driver
for the communication cable).
1) Connect the RQ-USB2UART to the laptop (PC).
2) Connect the yellow connector of the cable to the yellow port (Communication port) on
the back of RQC (RQ controller).
3) Check that the battery’s power cable is connected and turn on the RQC power switch.
SCRATCH BUILDER
Well done!
Let’s find out
about another
way to connect!
8
SCRATCH BUILDER 9
4. How to connect the USB2UART cable when using a Bluetooth chip1) Connect the Blutooth / RF socket to the
yellow port on the RQC.
2) Insert a Bluetooth chip to the socket.
3) Check that the battery’s power cable
is connected and turn on the RQC
power switch.
4) Go to Bluetooth device manager in your PC. Click Add Bluetooth or other devices and
choose RBT1111XXXX (Password is 1234 or 0000).
5) Run Scratch Builder software and select the Comport where the Bluetooth is connected,
and click ‘Connect’ to make a connection.
*If the connection fails, turn off and on the RQC and retry.
SCRATCH BUILDER 10
1. Open Scratch BuilderWhen you are ready with the RQ robot to control with Scratch, open Scratch Builder.
1) Open Scratch Builder on the desktop screen.
2) Select ‘Connect’ to make a connection for communication.
3) Select ‘Auto Connect’ for automatic connection.
Once the connection has been established,
the Connect icon turns green.
02 UNDERSTANDING SCRATCH BUILDER
SCRATCH BUILDER 11
4) Select ‘New Scratch’
5) Click ‘New’ on the Left to create a new file. Choose a robot platform and enter
a file name.
When creating a new file. Select a robot platform between the 3 choices. RQ
Robot covers all RQ kit series from +110 to the end, and Non-standard is for
models that user created.
SCRATCH BUILDER 12
6) A Scratch file under the given name is created. Double click the file to run the Scratch
software.
7) Click ‘More Blocks’ in purple on the Scratch screen to show the exclusive blocks for the RQ
robot (Nothing shows on More Block when Scratch is opened without Scratch Builder).
Now Scratch
Builder is opened,
should we learn
how to use
Scratch?
2. Understanding the Scratch screenLet’s learn how to control the RQ robot with Scratch.
SCRATCH BUILDER 13
Language,
Font size
Code start
and stop
Duplicate, crop,
size adjustment
Block Palette:
Divided into 10
block menus-
correspond to
different
functions
X, Y
coordinates of
the Sprite’s
positionSprite that moves
as codedScripts area:
The space to code with Scratch.
Scripts:
Bring block commands from the
palette to combine and use.
Costumes:
Draw, edit or open an image.
Sounds:
Open and use a sound file or
record.
Sprite block:
-Shows the Sprite in unit.
-Edit the Sprite.
Combine various blocks
from the palette to create
a Scratch program.
Adjust the block size in
the script space.
It looks complicated,
but you will soon
become familiar as you
follow step by step.
SCRATCH BUILDER 14
3. Basic Scratch blocks
No. Color Item Function
1 MotionMove Scratch’s Sprite in various ways (location change, angle, etc).
2 Event Select how to start the Scratch.
3 LooksChange the shape, background, color, speech bubble and form of show and hide.
4 ControlControl the block progress-run time, repetition (repetition time, infinite), condition, etc.
5 Sound Play sound from the PC and play various sounds.
6 Sensing Select various conditions.
7 PenSelect the method for erase, stamp (duplicate) and pen.
8 OperationSelect operation-related matters like the four arithmetical operations, a sign of inequality, and logical operation.
9 Data Create variables and lists.
10More blocks
Special blocks to control the RQ robot.
SCRATCH BUILDER 15
4. Using RQ robot control-related blocks (More Blocks)1) Moving forward, backward, left, right and more movements.
More block is a special
block that is necessary
for RQ robot control.
Let’s learn more about
More Blocks.
C
A
D
B
Matches between the direction options on Scratch builder and the buttons on remote
controller.
(1) Call motions
-Move forward
-Move backward
-Turn Left
-Turn right
SCRATCH BUILDER 16
Some robots move
differently depending
on its design, but for all
robots, pressing the
arrows make the motor
rotate to move the
robot.
(2) Set wheels
-Move forward
-Move backward
-Turn Left
-Turn right
SCRATCH BUILDER 17
The number inside the
block is the speed level. 1
means speed level 1, and
2 means speed level 2.
SCRATCH BUILDER 18
CW stands for
‘clockwise’ and CCW,
‘counterclockwise’.
This block directly
controls the motor’s
rotation directions.
(3) Rotation motor’s direction and speed
2) LED
(1) Turning on the LED
(2) Turning off the LED
Selecting the LED color
Selecting the LED color
Selecting the LED module
SCRATCH BUILDER 19
Turning on
Red for LED1
Turning on
Blue for LED1Turning on Red
and Blue for LED1
Turning on off
LED1
Turning on Red
for LED1 and 2
Turning on Blue
for LED1 and 2
Turning on Red and
Blue for LED1 and 2
Turning on off
LED1 and 2
SCRATCH BUILDER 20
(3) Make the red LED and the blue LED blink 10 times
in sequence.
(4) Make the red and the blue LED blink 10 times at the
same time.
(5) Make the red LED and the Blue LED blink 10 times very
quickly in sequence.
(6) Make the red and the blue LED blink 10 times very
quickly at the same time.
A good combination of
LED blocks and
makes a great LED
lighting.
SCRATCH BUILDER 21
3) Using Melody
(1) Turning on a melody
(2) Turning off the sound
Selecting a melody Selecting a scale
Turn off the melody
My favorite is Twinkle,
Twinkle, Little Star.
What is yours?
(3) Turn on the melody ‘Twinkle, Twinkle,
Little Star’.
(4) Play ‘Twinkle, Twinkle, Little Star for
only 5 seconds’.
(5) Play Do for 0.5 seconds.
(6) Play Do, Re, Mi for 0.5 seconds.
(7) Play Do, Re, Mi for 0.5 seconds (repeat 3 times)
(8) Play Do, Re, Mi for 0.5 seconds each and
pause1 second in between each note.
SCRATCH BUILDER 22
It’s this easy to make
the robot play sounds.
Shall we make a nice
song?
SCRATCH BUILDER 23
5. Using RQ robot sensorsUnlike other blocks, the sensor block needs to be used together with another blocks with
different conditions.
1) Sound sensor
(1) If the sound sensor detects sound louder
than 50, Move forward.
(2) If the sound sensor detects sound louder
than 50, play ‘Twinkle, Twinkle, Little Star’.
(3) If the sound sensor detects sound louder
than 50, blink the red and the blue LED 10 times
in sequence.
Example
If the sound sensor detects sound louder than 50,
SCRATCH BUILDER 24
2) Touch sensor
(1) If the touch sensor number 1 is on, move forward
(2) If the touch sensor number 1 is on, play ‘Twinkle, Twinkle, Little Star’.
Example
If the touch sensor is on,
If the touch sensor is off,
Connect the touch sensor to number 1 and number 3 sensor port
of the RQC (Smart controller). Choose between
or
SCRATCH BUILDER 25
3) IR Sensor (Infrared Sensor)
(1) If the IR sensor detects a value
greater than 150, move backward
and then stop.
(2) If the IR sensor detects a value
greater than 150, repeat blinking the
red and blue LEDs quickly.
Example
If the IR sensor detects a value greater than 50,
Connect the IR sensor to number 2 and number 4 sensor port of
the RQC(Smart controller). Choose between
or
SCRATCH BUILDER 26
6. Uploading Scratch codeBefore the upload, RQ robot should be connected to the computer. See 1-3 ‘How to connect’.
1. Code using Scratch
2. Run the Scratch code to check if it works correctly, and then click Save.
3. Save and then close Scratch.
4. On Scratch Builder, click Upload.
SCRATCH BUILDER 27
5. Drag the file you have just saved to the bottom left, following the arrow.
6. Click ‘Ok’ when upload pop-ups appears.
7. Once uploaded, the Upload successful message opens. Click ‘Ok’.
SCRATCH BUILDER 28
8. Remove the cable connected to the robot.
9. Direct a registered remote to the robot and press the stop button.
(When you push the button, the ringing sound plays).
10. Direct registered remote to the robot and press #+4.
11. With the ringing sound, coding begins.
12. If you have coded an infinite loop, press #+Stop to end coding.
(When the coding ends, it beeps).
How to change the font size on Scratch
1) Hold the shift button on the keyboard and click the globe icon to open a hidden
function (set font size).
2) Select the font size to 11 to make the font bigger.
3) Select the font size 11 or any number that your prefer to make the font bigger.
SCRATCH BUILDER 29
TIPS!
Sometimes, the text
inside the blocks are
so small on the
Scratch screen that
it’s difficult to read.
Let’s learn how to
change the font size
for texts inside the
blocks.
Learning objectiveCode to make RQ-HUNO stand up from its lying position.
1. Learn how to make RQ-HUNO stand up (Stand A, B).
Standing up when facing the sky (Stand A)
Standing up when facing the floor (Stand B)
Using Scratch’s ‘More blocks’ and ‘Control’, let’s code to distinguish whether the robot is
facing the sky or facing floor.
*Stand A and B motions are some of the basic behaviors including in RQ-HUNO’s firmware.
2. Learn how to make RQ-HUNO stand up when it hear a voice.
SCRATCH BUILDER 30
03 PROGRAMMING PRACTICE:WAKING UP RQ-HUNO
SCRATCH BUILDER 31
1. How to make RQ-HUNO stand (A,B)1) Select ‘More blocks’ to use special blocks to
control RQ robots.
2) From different blocks in the More blocks, use ‘Call motions’ to select ‘Button A’ (Stand A).
[List of Call motions]
CA
DB
See that they
represent the buttons
on the remote.
SCRATCH BUILDER 32
3) Drag and drop ‘Call motions’ block to the script area then select ‘Button A’ from its drop
down menu.
4) Then use the ‘Wait ( ) secs’ block from ‘Control’ section. We need this block to secure
enough time while ‘Button A’ (Stand A) is in action.
5) ‘Button A’ motion requires about 2 seconds. Not to interrupt the next block, use ‘Wait ( )
secs’ block to secure enough time. 3 seconds are better than 2 seconds for stability.
6) Put down RQ-HUNO as shown in the picture and click the Scratch block. RQ-HUNO then
stands up from its lying position.
Now that RQ-
HUNO stood up.
Let’s make it walk.
SCRATCH BUILDER 33
7) The block below will make RQ-HUNO stands up and takes a step forward.
8) Select ‘Repeat’ block from ‘Control’ section, then place it above the ‘Call motions button↑’block. Then change the time to 3.
Let’s make RQ-
HUNO walk
further!
Let’s run the code
and see what
happens.
When the Scratch block is running, a yellow band forms around
the blocks. When the yellow band is gone, it means the Scratch
block motion has ended.
TIPS!
SCRATCH BUILDER 34
9) Put down RQ-HUNO as shown in the picture and click the Scratch block. RQ-HUNO stands
up and takes 3 steps forward.
10) To play a melody while RQ-HUNO is in motion, let’s use ‘Sound on/off’ blocks from ‘More
blocks’.
11) Put down RQ-HUNO as shown in the picture and
click the Scratch block. RQ-HUNO stands up and
takes 3 steps and the melody plays. Once the motion
has been completed, the melody also stops.
This time, we are going to
make a melody play while
RQ –HUNO is in motion and
stop when all motions are
finished
SCRATCH BUILDER 35
12) The Scratch blocks below is for making RQ-HUNO stand up when it falls face down
(Stand B).
13) Put down RQ-HUNO (Facing down) as shown in the picture and click the Scratch block.
RQ-HUNO stands up and take 3 steps forward with playing the melody. Once the motion has
been completed, the melody also stops.
2. How to make RQ-HUNO stand up when it hears a voice.
1) Let’s make Scratch blocks as shown in the picture below. Use the same blocks from
previous chapter.
Use the same blocks we
made from the chapter 1. We
add more lines to make RQ-
HUNO hears a voice.
Let’s find out how we can use
to detect a voice.
SCRATCH BUILDER 36
2) Drag ‘Sound sensor’ block with the mouse to insert into .
3) Enter 50 as the basic sound volume in the blank. This means ‘The value of detected sound
is greater than 50’.
From ‘More Blocks’, check , thenwill appear on the top left stage.
If the robot’s power is on and the communication connection has been made properly, the volume of sound around the robot is displayed with a number.When using the sound detection function in Scratch, check the volume of sound measured before setting a basic value.For example, if the volume of sound measured is 60, set the basic value to 50 for stable sound detection.In other words, it is better to set the basic value a slightly lower than the actual measurement.For reference, the sensor values for the sensors other than Sound sensor block will not appear immediately.
TIPS!
SCRATCH BUILDER 37
4) Select ‘If then’ block from Control blocks to make blocks as below.
It is the part that says ‘If the value of sound measured is greater than 50, then execute XXXX.’
Drag the conditional phrase block to cover the block that you created already.
5) A conditional block like ‘if’ may not work even blocks have been inserted into ‘if’ part. This
is because it only performs once and then does not repeat. Use ‘Forever’ block from
Condition block section to repeat specific blocks infinitely.
You can not detect sound
only with .
You will need a conditional
block.
Condition
Execution
We use ‘Forever’ block with ‘If’
block to detect sound at any
time.
SCRATCH BUILDER 38
6) Lastly, place ‘Wait ( ) secs’ block under ‘Sound off’ block, then put 1 second in the blank
7) Put down RQ-HUNO as shown in the picture and click the Scratch block. When you click, it
does not do anything. But when you shout, “Wake up”., or clap to make some noise, RQ-
HUNO stands up and take 2 steps forward with playing the melody.
8) If you change ‘Call motions block’ as below, RQ-HUNO will stand up and move 2 steps
when RQ-HUNO lays face down.
If there is no ‘Wait 1 secs’ block, the
program starts from the beginning as
soon as the sound is turned off with
‘Sound off’ block, then it can detect the
sound from robot moving. That is why it
waits for one second after the sound is
turned off.
Issued date: January 9th, 2018
Publisher: Robobuilder Co.,Ltd.
Address: B-611, DMC Hi-tech Industry Center, Seongam-ro 330, Mapo-gu, Seoul, Korea
03920
Tel: +82-2-3141-5101
E-mail: [email protected]
Web: www.robobuilder.net
Copyright by Robobuilder Co.,Ltd. All rights reserved.
No part of this publication may be reproduced or distributed in any form or by any means,
without the prior written permission of the publisher.