0% found this document useful (0 votes)
115 views57 pages

Codey Rocky Coding Guide - EN

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 57

Code for Fun with

Codey Rocky

mBlock

www.makeblock.com
Contents

01 用按钮切换小程的表情
Change Codey's Emotions
with Buttons

02 Use Codey to Create


LED Animations

03 Turn Codey into a Musician

04 Make Codey Blink Eyes

05 Make Codey Rocky


Identify Colors

06 Make Codey Rocky


Avoid Obstacles

07 Use Codey to Make Sprites


Play Instruments

08
Design a Controller for
Codey Rocky

09 Make a Number Bomb Game


Codey Rocky

Codey Rocky is a caterpillar tracked robot. It integrates over 10 electronic blocks,


including sound sensor, light sensor, LED screen and more. And with just a few
lines of code, you can easily make Codey Rocky do all kinds of amazing things,
like playing music, chasing lights or changing facial expressions like humans.

Codey Combine Codey with Rocky and


then you get Codey Rocky!

Rocky
A Tour of the Interface

Menu Switch languages (CH/EN), Open files, Save files, Example programs, Help, etc.

iPad

Stage Blocks Area Script Area


You can show off your projects, In this area, you are This is the place where
connect devices, set your able to find the blocks you drag blocks to
sprites and customize the you 'll need by category write programs.
backgrounds here. or color.

Connecting Codey Rocky to mBlock 5

1.Open mBlock 5. Connect Codey to your computer using the USB cable.
(The on-screen instructions will tell you how to do when you are
connecting Codey to the mBlock app.)

-2-
2. Powering on:Press the power button to turn on Codey.

3.Connecting:You can find the Connect button in the stage area.

Select
the serial
port
number
and click
Connect.

Scan the QR code on the left side to check out the


demo.Note: The "COM3" here refers to the serial
port number and it may vary due to different
systems or computers. Anyway, you can just click
" Connect " to move on to the next step.

-3-
Quick Start

Create a Codey Rocky Project

Drag the play


sound block
to the script
area.
(You can
quickly locate
the blocks you
need by
color.)

The blocks are in different colors and shapes.


But they are able to connect to each other.
Now, you need to drag out the when Codey
is shaking block and combine it with the play
sound block. Here is what your code should
look like.(How to delete the program: Drag
the program back to the blocks area or you
can right click the blocks to delete them.)

3 After finishing your program, click Upload to Device


to store the program in Codey. In this way, you can
run the program even when Codey is disconnected
from mBlock 5.

Try shaking Codey!

-4-
Create a Stage Project

Below the stage area, click Sprites and click + to add a sprite you like.
(The panda is the default stage sprite.)

If you want to delete a sprite, just click ‘’×’’ in the upper right corner of the
sprite or right click the sprite icon to select delete.

OR

Make the sprite move. Drag the move 10 steps block to the script area.
Click on the block to check how the sprite moves exactly.

-5-
3 Give the sprite a sound effect and add an
event block. Combine the two blocks with the
move 10 steps block. Ok, now you've
completed the program for your sprite!

Click the icon’’ ‘’at the bottom right corner


of the stage to run the program. As
programmed, the bat will move 10 steps
forward and play the sound “pop”. To pause
the program, click on” ”.

4 Remember to save your program! Click "Save as" under the Menu to
save your program to local.

3
2

Try making your own project and share it with friends!

-6-
Change Codey's
Emotions with Buttons

Codey

Scan the QR code


to view the demo
Create

1 Add a sound effect


Drag the play sound block to the script area.

You can select another sound.

2 Give Codey Rocky its expression


In the Display category, you can find the show image block. Drag the
block to the script area and add it to the end of the play sound block.

You can edit the image.

Use the toolbar to draw


an image yourself.

Or pick an image here.


3 Add an event
Add the when button A is pressed block to the previous blocks.
This is how your code should look like:

You've added a piece of code to Codey


Rocky. Next, upload the code to test
whether it can work as expected!

tures
Explore more fea

Try adding the following programs to


Codey Rocky as you just did!
Have a Try

Upload the code to Codey Rocky. Then try pressing the


button A, B and C.(Remember to save your programs)
Challenge

Can you use the three buttons to let


Codey Rocky show more emotions or
make different sounds?
Use Codey to create
LED animations

Codey

Codey is able to show different images. So the


mission of this booklet is to teach you how to
animate those images. Scan the QR code to
view the demo.

Scan the QR code


to view the demo
Create

1 Add an image
Drag the show image for 1 sec block to the script area.

You can reset the time.

Click here to draw an image. Use the toolbar


to refine or save the image.

Toolbar

Repeat the steps above to give the rabbit different motions.


2 Add a sound effect
Add the play sound block to the code.

You can pick another sound effect.

3 Add a loop
Drag the repeat 10 times block to the script area
and use it to encircle other blocks.

You can reset the times.


4 Add an event
Select the when Codey is shaking block from the
Events category and add it to the code.

You've completed the code for making an LED animation. Now


you'll need to upload the code to Codey Rocky. Then try shaking it!
Or you can tie Codey to your body. Notice how Codey reacts when
you keep jumping?
Have a Try

Remember to save the program!

Challenge

Can you create your own LED


animations by drawing some
different images? Give it a try!
Turn Codey into a Musician

Codey

Scan the QR code


to view the demo
Create

1 Add a note
Drag the play note C3 for (0.25) beats block to the script area.

You can reset the beat.

Click here to select a note.

Repeat the step to set different notes and snap the blocks together.

2 Add an event
Attach the when button A is pressed block to the top of the code.

1 Now the code for making Codey play


music is ready. You can upload the code
to Codey to test how it works. Try
guessing what music Codey is playing?
3 Add the volume control
Drag the set volume to (100) block to the blank space in the script area.

Note:Don’t add this block to the previous code.

4 Add the gear potentiometer block


Drag the gear potentiometer block and put it inside the set volume block.

Tip
Gear potentiometer
Gear potentiometer is an input device
that can be used to adjust values.
Using the gear potentiometer, you
can change the volume of Codey and
the brightness of the indicator light.

Note: You can't directly join these round


blocks to other blocks.
5 Add a loop
Encircle the set volume and gear potentiometer
blocks with the forever block.

6 Add an event
Drag the when Codey starts up block to the top of the group
of blocks you've designed in the step 5.

2 Now you've finished another


program! Upload the program
to Codey. Try changing the
volume of the music!
Have a Try

Upload the program and press the button on Codey.


Wait! Remember to save your program!

Challenge

Can you give Codey more sound


effects or make Codey show light
effects while playing music?
Make Codey Blink Eyes

Codey

Scan the QR code


to view the demo
Create

1 Give Codey a facial expression


Drag the show image for (1) sec block to the script area.

You can reset the time.

Click here to select or draw an image.


Use the toolbar to revise and save the image.

Toolbar

Select an image

Repeat the steps above to add different images. Join the


two blocks together.
2 Add a loop
Then you'll need to use the forever block. Drag the block
to encircle the code.

3
Add an event
Drag the when Codey starts up block from the Events
category and add it to the code.

Ok, you've finished the program for


making Codey blink eyes. Try uploading
the program to Codey to test it. But how
to make the blinking look more natural?
4 Make Codey blink eyes randomly
In the Operators category, you can find the pick random (1) to (10) block.
Put the block inside the show image for (0.2) secs block.

You can change the random numbers .


Note: You can't directly join these round
blocks to other blocks.

Upload
your program to
Codey to test it. Can you
notice? I'm blinking eyes at
varied intervals!
Have a Try

Remember to save your program!

Challenge

Can you make Codey show


different facial expressions?
Make Codey Rocky
Identify Colors

Codey Rocky

Scan the QR code


to view the demo
Create

1 Add a sensor
Drag the color is red block to the script area.

You can reset the color.

2 Add a control block


Drag the if/then block to the script area and put the color is red
block inside that hexagonal hole.

Note:Hexagonal blocks can't


directly join to other blocks.

3 Add a light effect


Drag the RGB LED lights up block into the if/then block.

You can click here to


reset the color.
4 Add a sound effect
Drag the play sound (score) block from the Speaker category
and add it to the code as shown below.

You can select another sound effect.

5 Add an event
Add the when Codey starts up block to your code.

Ok, you've finished the code for enabling Codey Rocky to


identify red items. Now upload the code to Codey and
place a red item before Codey Rocky. See how it reacts?
But if you want to empower Codey Rocky to identify
more colors, you'll need to add another piece of code!
Repeat the steps 1-4 to make your code look like this:

6 Add a loop
Drag out the forever block and use it to encircle the code like this:

Now
Codey Rocky should
be able to identify two
colors. So why wait? Upload
the code to test whether
it works!
Have a Try

Important: Make sure you keep the


IR sensor face down.

Challenge

Try using different colored materials to make items


for Codey Rocky to identify. And revise the code to
have Codey Rocky show different reactions.
Make Codey Rocky
Avoid Obstacles

Codey Rocky

Scan the QR code


to view the demo
Create

1 Add an image
Drag the show image block to the script area.

2 Add a motion
Find the move forward at power 50% block in the Action category.
Then add it to the show image block.

3 Add a sensor
Drag the obstacles ahead? block to any blank space of the script area.

Note: Hexagonal blocks can't


directly join to other blocks.
4 Add a control block
Drag the wait until block to the script area and put the obstacles ahead
block inside the hexagonal hole. Then join the two pieces of blocks like this.

5 Make Codey Rocky stop moving


Add the stop motion block to your code.
6 Add motions
First add the move backward at power 50% for 1 sec block to the code
and then add the turn right at power 50% for 1 sec block.

7 Add an event
Add the when Codey starts up block to your code.

Ok, the code is ready now. Upload it


to Codey Rocky to test how it
works. Then try placing an item in
front of the robot. What happens?
8 Add a loop
Encircle your code with the forever block as shown below.

Now, Codey Rocky is able to


stay away from obstacles
whenever it meets them.
Important: You should keep the IR sensor face forward.

Have a Try

Look, Codey Rocky is able to avoid the obstacles!


Challenge

Try using the block in your code


to make Codey Rocky stay away from cliffs.
Make sure you make the IR
sensor face down.
Use Codey to Make
Sprites Play Instruments

Codey

Scan the QR code


to view the demo
Create

1 Add the broadcast


Drag the broadcast message block from the
Events category to the script area.

You can create a new message.

2 Add an event
Combine the when button A pressed block with the
broadcast block like this.

3 Add a sprite
Click Sprites under the stage to add the sprite drum.

Tip
Each device or sprite has
its specific script area.
4 Add a sound effect
Drag the play sound high tom block to the script area.

5 Add a costume
Add the switch costume to drum-a block.

You can change the costume.

6 Add a control block


Add the wait 1 sec block to the code in the following way.
7 Add a costume
Add the switch costume to drum-a block.

8 Add an event
Drag the when I receive A block to the top of the code.
Make sure your code looks like this.

Ok, the code is ready. Now


upload it to Codey Rocky to test
how it works!
Have a Try

Press the button. Let's


hear the drum sound!

Challenge

Can you add more


sprites to form a band?
Design a Controller for
Codey Rocky

Codey Rocky

Scan the QR code


to view the demo
Create

1 Add a sprite
Select the sprite arrow1 from Sprites under the stage.

2 Add the broadcast


Drag the broadcast message block to the script area of the arrow1.

You can create a new message.

3 Add an Event
Add the when this sprite clicked block to the broadcast block.
Repeat the steps above to add four arrows indicating different
directions. You can click Costumes to change the direction.

Tip
Each device or sprite has its specific script
area, so you'll need to make sure you place
the three groups of blocks above in the
correct script area.
4 Add a motion
Click Devices under the stage. Then drag the move forward at
power 50% for 1 sec block to the script area.

5 Add an event
Use the when I receive up block in your code.

You can select another direction here.

Finish the code for the rest arrows as you did in the step 4 and step 5.

Finish the code for


the rest arrows as
you did in the step
4 and step 5.
Have a Try

Click the arrows to check how Codey Rocky reacts.

Challenge

You can try adding some other icons


to empower the controller with more
abilities, like sound control or facial
expressions control.
Make a Number Bomb Game

Codey Rocky
Create

1 Create a variable
Click the Variables category and click Create variable. Name your
variable as number and then click OK.

2 Add a value
Drag the set number to 0 block to the script area.

3 Add the display block


Click the Display category to add the show hello until done
block to your code.
4 Add a variable
Find the number block in the Variables category. Drag it into the
show hello until done block. Your code should look like this.

5 Add an event
Add the when Codey starts up block to the code.

6 Add the value


Drag the change number by 1 block to any blank space in the script area.
Repeat Step 3 and Step 4.

7 Add a sound effect


Drag the play sound hello block from the Speaker
category and add it to the code you've just created.

You can reset the sound effect.


8 Add an event
Add the when button A is pressed block to the
code you've finished in Step 7.

Ok, the code is ready. Now


upload it to Codey Rocky,
turning the robot into a timer!
Level up
Make a number bomb game to challenge
your friends. Two players take turns pressing
the button A. At the same time, the number
is growing. The one that triggers the bomb
will lose the game.
Have a Try

Invite your friends to play the game!

Challenge

Revise the code above. Make sure


the game will start over when the
button C is pressed.

You might also like