Elementary
Programming

Fundamentals
A Basic Programming and Software Guide

Introduction
About This Book
This textbook explains how to use the ArtecRobo 2.0 programming platform to let
students build and program their own robots, allowing them to see for themselves
how computers and programming make the technology they use in their daily lives
work. The textbook is divided into two parts: Fundamentals and Applied
Programming. This is the Fundamentals textbook, where you can learn basic
programming as well as how to use the ArtecRobo 2.0 hardware and the Studuino:bit
Software. The Applied Programming book presents a series of example learning
projects based on diﬀerent topics in programming and technology, allowing you tochoose a topic you want to focus on in your class.

Index

1. Computers and Programming .................................................................................. 4
Learn the roles computers and the programs behind them play in our lives.

2. The Studuino:bit Software ........................................................................................ 7
Learn about the programming software used in this book as well as how to use it to run
programs. ..........................................................................................................................

21

3. Using the Core Unit
Learn how to use the ArtecRobo 2.0 Core Unit's built-in LED display, buzzer, and sensors.
●

The LED Display ...................... 22●

The Light Sensor .................................. 34●

The Buzzer ................................. 26●

The Temperature Sensor .................. 38●

The Buttons ............................. 29●

The Accelerometer ............................. 42

4．Using Electronic Parts ................................................................................................ 49
Learn how to expand your Core Unit's functionality by adding parts.
★ The instructions in this book assume you are using the software on a computer. If you are using
a tablet, please substitute "tap" for "click" and "swipe" for "drag" in the instructions.

★ If your Core Unit will be out of use for an extended period of time, disconnect the Core Unit fromthe Battery Box. The unit consumes electricity passively to monitor its buttons, which will use up thebattery in about one week.

★ Names of products and services appearing in this textbook are the property of their respective
owners.
・ Windows is a registered trademark of the Microsoft Corporation, registered in the U.S. and other countries.
・ Mac OS is a registered trademark of Apple Inc., registered in the U.S. and other countries.
・ iOS refers to the OS from Apple Inc. IOS is a registered trademark of Cisco Systems, Inc. and its aﬄiates,
registered in the US and other countries, and is used under liscense.
・ Apple Store is a service mark of Apple Inc.
・ Android, Chromebook, and Google Play are registered trademarks of Google LLC.
・ ArtecRobo 2.0 and Studuino:bit are registered trademarks of Artec Co., Ltd.

1

Introducing ArtecRobo 2.0
The ArtecRobo 2.0 educational programming platform uses two main parts: the Core Unit, which is aminiature computer, and the Robot Expansion Unit, which you can connect to the Core Unit to use extra
electronic parts.
Temperature Sensor (page 38)

Core Unit

Light Sensor (page 34)

A ButtonTop

B Button(page 29)

(page 29)5 x 5 Full Color LED Display (page 22)
USB Connector
Power Connector
Buzzer (page 26)

Back

Reset Button

Microcontroller

Robot Expansion Unit
Core Unit(Right Side)(Front)（9-Axis Sensor
3-Axis Accelerometer(page 42)3-Axis Gyroscope
3-Axis Compass）(Left Side)★ The Core Unit can beconnected facing the
opposite direction as well.

(Bottom)

Robot Expansion Unit

★ Plug electronic parts into the ports
marked in red!

Electonic Parts Used in This Book

● DC Motor (page 51)● IR Photoreﬂector (page 56)

2

Combining the ArtecRobo 2.0 Core Unit and Artec Blocks lets you build and program
all kinds of robots, computer systems, and other projects. The Elementary
Programming textbooks use the following seven kinds of Artec Blocks:

Basic Cube
(White)Half A(Light Gray)

Disk

Half C(White)

Wheel

Beam

O-ring(Wide)In the Applied Programming book, you'll use these blocks to build projects like these:

3

Traﬃc Control: Traﬃc Lights

Preparing for Disaster:
Earthquake Dectectors

Automation: Self-Driving Cars

Traﬃc Safety:
Collision Avoidance Systems

1. Computers and Programming
Start your class by getting your students to think about how computers are used every
day in the world around them, and explain how programming makes those computerswork.

1-1. Everyday Devices That Use Computers
Many of the electronic appliances we use in our daily lives work by using built-in
computers. Let's think about how ticket gates in train stations and home washingmachines work to get an idea of how devices like these use computers so they can
do various tasks automatically.

Ex. 1) Ticket Gates

Ex. 2) Washing Machines

DeviceWhat does the computer do?

Ex. 1)
Ticket Gates

Reads information from a ticket or fare card and orders the gate to open or

Ex. 2)
Washing Machines

Judges how much laundry is in the machine when you press the button,

close depending on what it reads.

then determines how much water the machine should use to wash it.

41-2. Controlling Computers with Programs
To make a computer do what you want it to, you need to give it directions in a form
we call a (computer) program. A program is made up of a series of directions for acomputer to follow, which the computer can read and carry out. Programs are written
by human beings, who think of something they want a computer to do, then write out
directions to tell the computer how to do it. Writing programs for computers is called
programming. When you write a program, you need to use a special language thatcomputers can understand, which is called a programming language.

Decide what directions you need to give

Write a program that gives

to make the computer do something.

those directions to the computer.

This is a program written
in a programming
language!

Programming languages come in two main types: text-based languages andvisual-based languages. In this class we'll be using an easy-to-understand visualprogramming language.
Text Languages
Write directions for the computer using letters, numbers, and other characters.
What This Program Does

Turn on all LEDs in red
Wait 1 second
Turn oﬀ all LEDs

Visual Languages
Make directions for the computer
using on-screen icons.

5

1-3. Basic Program Organization
Programs are made of series of commands, each of which tells the computer to carryout a process like recording data, changing data, or controlling physical parts. There
are three basic ways you can organize the commands in your program: sequences,loops, and branches.

Command

Sequential

Programming

Description

The computer will carry out

Command 1

each command in the order
you give them.

Command 2

Start the loop
The computer will carry out

Command 1

Loops

the same command orsequence of commands

Command 2

over and over.

Repeat from the start

The computer will carry out
a diﬀerent command orsequence of commands

Condition

Conditions

depending on whether acertain condition is fulﬁlled.

Case A

Command A

Case B

Command B

In this diagram if thecondition Case A is true thecomputer will follow

Command A, but if thecondition Case B is true, itwill follow Command B.

62. The Studuino:bit Software
To write programs you can transfer and run on the Core Unit, you'll need to use theStuduino:bit Software.

2-1. Installing the Software
Find your device's operating system listed below, and follow the instructions
to install the software.

● Windows
Follow the URL below to download the software:

https://www.artec-kk.co.jp/artecrobo2/en/software/
Run your downloaded setup ﬁle to install the Studuino:bit Software.

● Mac OS X
Follow the URL below to download the software:

https://www.artec-kk.co.jp/artecrobo2/en/software/
Find the application Studuinobit.app in the downloaded ﬁle and move it into
the Applications folder.

● Android／ChromeBook
Search for Studuino:bit in the Google Play Store and install the software from there.

● iOS
Search for Studuino:bit in the App Store and install the software from there.

Youʼll see the icon to the right appear on your screen once theinstallation has ﬁnished.

7

2-2. Starting Up the Software
Follow these steps to start up the software and open the programming interface.

❶ Click the Studuino:bit icon
to start up the software.

❷ Select Robot mode after the software
starts up to enter the programming screen.

Choose from rom English, Spanish, French, Korean,
Japanese (kanji), Japanese (hiragana), Portuguese, Russian,or Chinese (traditional).

★ As of version 1.4.2.

Menu

The Script Area:
Put blocks together tomake your programs here.

Block Palette:
Find the blocks (commands) you can use to make programs here.
Catergories:
The Block Palette is divided into diﬀerent categories of blocks (commands). Click on the icon for acategory here to jump to its section of the Block Palette.

82-3. Using the Software
The Studuino:bit software allows you to drag and drop blocks to program your Core
Unit and electronic parts.

● Making Programs
To make a program, just drag and drop blocks (commands) from the Block Palette
into the Script Area and put them together.

Drag & drop

The blocks connect to each other!

● Deleting Blocks
To delete a block, drag and drop it from the Script Area to the Block Palette.

Drag & drop9

Reference

The Block Categories

The blocks are divided into diﬀerent categories based on their functions.
There are ten categories in total: Motion, Looks, Sound, Events, Control,
Sensing, Radio, Operators, Variables, and Functions.
Category

Description
Blocks which control electronic parts like DC Motors and Servomotors.
To get the blocks from this category to appear, you need to ﬁrst haveat least one motor selected in Port Settings.
Blocks which control the LEDs in the Core Unit's LED display.

Blocks which control the Core Unit's Buzzer.

This block marks the start of a program.

Blocks which control the order and timing of the commands
your program gives the computer.

Blocks which look up information detected by speciﬁed sensors.

Blocks which send and receive wireless signals. ★ Not used in this book.

Blocks which you can use to make the computer perform calculations,or to set up conditions for your program.
Make variable and list blocks you can use to record information.
★ Not used in this book.

Make your own function blocks. ★ Not used in this book.

For further information on the block types not featured in this book, click the Tutorials
button in the software menu.

102-4. Running Your Programs
There are two options in the software you can use to run your programs on the Core
Unit: Connect and Transfer. Connect opens a constant connection between the Core
Unit and your computer or tablet. The program will run on your computer, which will
send the program's commands to the Core Unit over the existing connection. Transfer
will send your program to the Core Unit and save it there. Then the Core Unit can run
the program itself.
Connect

・The program will run on your PC
Commands

Runs your program

Transfer

SignalSends signal

・The program is saved to your Core Unit.
・Your Core Unit runs the saved program.
Your Program

Sends program

Saves program

SignalRuns your program

When using Connect or Transfer, your device will need to be connected to the Core
Unit using either a USB cable (if you're using a computer) or a wireless Bluetoothconnection (if you're using a tablet).

Connecting with a Computer

Connecting with a Tablet

Transferring your programs and running them on the Core Unit itself can be moreconvenient as it doesn't require you to maintain the USB/Bluetooth connection and theprogram will run faster.

11◆ Making a Test Program

Test out the process by making a program that uses the buzzer to play the note
Do for 1 second, then try running it on each device using Connect and Transfer.
See page 26 to learn how to use the buzzer.

❶ Drag a

block from the Events category into the Script Area.

Script Area

Block Palette

Categories❷ Take aconnect it to theblock from the Sound category andblock.

❸ Follow the instructions on pages 13-14 (if using a Windows or Mac device)or pages 15-18 (if using an Android/Chromebook or iOS device) to run
your program from ❷ using both Connect and Transfer.

12◆ Connect and Transfer (for Computers)

On Windows or Mac (USB cable connection)
If you're writing your programs on a computer, you'll need to use a USB cable
to connect to the Core Unit and run or transfer your programs. Let's try running
the test program you made on page 12.

Running Programs with Connect❶ Connect your Core Unit to your computer using a USB cable.

PC
Core Unit❷ When you select Connect from the Studuino:bit Software's Edit menu,

the Sensor Board window will appear on the upper right side of your screen.

❸ Click theblock torun your program. It will make thebuzzer play for 1 second.
A yellow outline will appear around program
blocks that are currently running.

13

Click!

Running Programs with Transfer❶ Connect your Core Unit to yourcomputer using a USB cable.

❷ Select Transfer from the Studuino:bit
Software's Edit menu.

❺ Select a slot on the Core Unit from 0 to 9 to send the program to. You
can also rename the program here.

❻ When the transfer is complete, the Core Unit will start running the

program automatically. To restart the program from the beginning, press
the Reset button.
If the transfer is successful, the LED in the upper right corner of the display will light up

blue. If the transfer fails, the same LED will light up white instead. If this happens, press theReset button and try again.

Successful
ul Transfer

Blue light

Failed Transfer

White light

See page 19 for instructions on how to run programs that are saved in the Core Unit's other slots.

14◆ Connect and Transfer (for Tablets)

On Android/Chromebook or iOS (Bluetooth wireless connection)
If you're writing your programs on a tablet, you can connect to the Core Unit
and run or transfer your programs wirelessly using Bluetooth. Let's try running
the test program you made on page 12.

Running Programs with Connect❶ Set up your tablet and yourCore Unit.

❷ Select Connect from the Studuino:bit
Software's Edit menu.

❸ Once the screen shown below appears, hold down the Core Unit's
B button and press Reset.

Reset Button
B Button15❹ When the Core Unit's LED display lights up, let go of the B button. Find thedevice with the with the same pattern as the Core Unitʼs display in the list
on screen, and press Connect.

If no device with a pattern matching the one on your Core Unit's display is shown, press Refresh.
If the LEDs switch oﬀ during this process, hold down the B button and press Reset again.

❺ The Core Unit's Communications Light
will turn on and the Sensor Board willappear on your screen.

Communications Light❻ Click the

さされ
された
れた ]

block to run your program. It will make the buzzer

play for 1 second.

Click!

A yellow outline will appear around program
blocks that are currently running.

16

Running Programs with Transfer❶ Set up your tablet and yourCore Unit.

❷ Select Transfer from theStuduino:bit Software's Edit menu.

❸ Once the screen shown below appears, hold down the Core Unit's B
button and press Reset.

Reset Button
B Button

If your tablet and Core Unit are already connected, go to step ❹.

17❹ When the Core Unit's LED display lights up, let go of the B button. Find thedevice with the with the same pattern as the Core Unitʼs display in the list
on screen, and press Connect.

If no device with a pattern matching the one on your Core Unit's display is shown, press Refresh.
If the LEDs switch oﬀ during this process, hold down the B button and press Reset again.

❺ Select a slot on the Core Unit from 0 to 9 to send the program to. You
can also rename the program here.

❻ When the transfer is complete, the Core Unit will start running the

program automatically. To restart the program from the beginning, press
the Reset button.
If the transfer is successful, the LED in the upper right corner of the display will light up

blue. If the transfer fails, the same LED will light up white instead. If this happens, press theReset button and try again.

Successful
ul Transfer

Blue light

Failed Transfer

White light

See page 19 for instructions on how to run programs that are saved in the Core Unit's other slots.

18

Reference

Selecting a Program to Run

You can pick which of the programs saved on your Core Unit you want to
run using the following steps.

❶ Powering On
1) Plug the Battery Box or a USB cable
into the Core Unit.
2) The Core Unit will turn on and the green
power indicator will light up. When you
turn on the Core Unit it will automaticallystart running the last program it ran.

❷ Program Select Mode
1) Hold down A and press the Reset button.

Reset Button

This will restart the device, so the power
indicator will turn oﬀ brieﬂy.
2) If the indicator turns back on 3 seconds
after you release the Reset button,

ButtonAthen release the A button.
3) If the display shows a 0 in green LEDs,
you have entered Program Select Mode.

❸ Program Selection/Start-Up
1) Pressing the A button when in Program
Select Mode will change the number on
the display, starting at 0 and going up to
9 before returning to 0.
2) Pressing the B button when a number ison the display will run the program thathas been saved to that slot number.
Every Core Unit comes loaded with demo programs for testing purposes.
Transferring a new program from the software to one of the program slots will overwrite
the demo program in that slot.

192-5. Saving and Loading Programs
The Studuino:bit Software lets you save your current program and load it to keep
working on it later:● Saving a Program
Select Save to your computer from the Studuino:bit Software's File menu.

● Loading a Program
Select Load from your computer from the Studuino:bit Software's File menu.

20

3. Using the Core Unit
The Core Unit itself is equipped with eight onboard parts: an LED display, a buzzer,
two buttons, a light sensor, a temperature sensor, an accelerometer, a compass, anda gyroscope. In this chapter youʼll learn how to use these built-in parts.
Front
Temperature Sensor

A Button

LED

Light Sensor

B Button

Back

Accelerometer

BuzzerGyroscopeCompass (Magnetometer)

Sensors like the accelerometer, gyroscope, and compass can be used in more advanced
programming lessons, but we recommend focusing on the comparatively simple light sensor,
buttons, and temperature sensor in your class.

21

3-1. The LED Display
The LED display is made up of 25 individual LEDs in a 5 x 5 grid. You can make eachand every one light up in any color you want. Each individual LED has speciﬁc X and Y
coordinates to describe its position, as shown below.

X
0

1

2

3 4

0

Y

1
2
3
4

The Studuino:bit Software lets you set all kinds of colors for your LEDs by setting theiramount of red, blue, and green to any value from 0 to 31 (red, blue, and green are theprimary colors of light). The way diﬀerent colors of light combine to make new colors
is called additive color mixing.
Blue
0

0 31

The Primary Colors of Light
31

0

0 31

Magenta

White
31

Red

31 0

Red Level

Green Level

Blue Level

Resulting Color

31

0

0

Red

31

15

0

Orange

31

31

31

White

0

31

31

Cyan

31

Yellow

31

31 31

Green
0

0

31 0

22

3-1-1. LED Programming Blocks
There are six kinds of blocks in the Looks category used to control the LED display.

● To turn on speciﬁc LEDs: [LED の XY で点灯 b]
Specify a color and an LED's coordinates in this block to light up that LED.
Ex.) Make the LED at X=2, Y=2 light up white:● To turn oﬀ speciﬁc LEDs: [LED の XY を消灯 b]
This block turns oﬀ an LED at the speciﬁed coordinates.
Ex.) Turn oﬀ the LED at X=2, Y=2:

X=2, Y=2 turns oﬀ● To display text: [LED に Hello!b]Write text in this block to make it scroll across the LED display.
Only alphanumeric characters will work.
Ex.) Show a red letter A:
The display scrolls

23

LED に表示させるに表示させる b]b]● To make an LED pattern: [L[LEDThis block lets you use the LED display to make a multicolored pattern.
Ex.) Make the pattern shown in the picture:● To turn on the whole display in one color: [[LED
LED を
を全て点灯
全て点灯 b]b]This block makes all of the LEDs in the display light up in the speciﬁed color.
Ex.) Make the whole display light up in blue:

D を全て消灯 b]● To turn oﬀ the whole display: [LEEDを全て消灯b]
This block turns oﬀ all of the LEDs in the display.

24

3-1-2. An Example LED Display Program

1 second

The following program makes
the LED display light up blue
for one second.

❶ Drag a

block fromthe Events category into the Script Area
to mark the start of the program.

❷ Add ablock fromthe Looks category and set its color to blue.

❸ Add ablock fromthe Control category.

❹ Add ablock fromthe Looks category.

❺ Connect to the Core Unit and click the program to see how it works!
To learn how to connect to the Core Unit with a computer, see page 13. For tablets, see page 15.

25

3-2. The Buzzer
You can also program which notes the buzzer plays as well as how long it plays them.
This textbook uses numbers to describe diﬀerent musical notes in its programs, but
the software also has an onscreen keyboard which you can use to pick notes.

Buzzer

Reference

Musical Notes and Their Numbers

Each key on the keyboard has its own value, and these values go up by 12
for each octave. These note values are standard notation used for the MIDI
technical standard, a format that allows performance data to be shared
between diﬀerent digital instruments.

49 51
C# E♭
Do# Mi♭

48 50
D
C
Do Re

52
E
Mi

54 56 58
F# G# B♭Fa# Sol# Ti♭

53 55 57FG
A
Fa Sol La

61 63
C# E♭
Do# Mi♭59 60 62
DC
B
Ti Do Re64
E
Mi

66 68 70
F# G# B♭Fa# Sol# Ti♭

65 67 69FGAFa Sol La

71
B
Ti

72
C
Do

26

3-2-1. Buzzer Programming Blocks
There are three blocks in the Sound category which you can use to control the Core
Unitʼs buzzer.

● To play a note: [[ブザーから#を鳴らすb]
ブザーから#を鳴らすb]
Set a note in this block make the buzzer play it.
Ex.) Make the buzzer play the note C (60):● To play a note for a set time: [ブ[ブザーから#を１秒鳴らすb]
ブザーから#を１秒鳴らすb]
Set a note and a length of time in this block make the buzzer play that notefor that amount of time.
Ex.) Make the buzzer play the note C (72) for 3 seconds:t● To stop playing a sound:This block shuts the buzzer oﬀ.

27

3-2-2. An Example Buzzer Program
The following program makes the buzzer play the note E (64) for just one second.

❶ Drag a[旗ががクリックされたb]
クリクリ クさされれたたbb]
クリック

block from the Events

category into the Script Area to mark the startof the program.

❷ Add ablockfrom the Sound category and set its note
to 64.

❸ Connect to the Core Unit and click the program to see how it works!
To learn how to connect to the Core Unit with a computer, see page 13. For tablets, see page 15.

Reference

An Alternate ProgramThis program does the same thing as
the one we just made!

28

3-3. The Buttons
The Core Unit has two face buttons, the A
and B buttons, and you can makeprograms which detect when these buttons
are pressed.
A Button

B Button

3-3-1. Button Programming Blocks
There are three kinds of blocks in the Sensing category which you can use to program
the Core Unitʼs buttons.

● To make your program start when you push a button:

Program blocks connected to this one will run when you push the button.

● To push a button to run a condition:
Put this block into the □in Control category blocks to set up conditions

for branching programs.
Ex.) Make the condition "if Button A is pushed":29

● To detect if a button is being pressed:
This block acts as a numeric value which tells whether the speciﬁed button is beingpressed. Connect to your Core Unit and youʼll see that a buttonʼs value changes to 0
when the button is pressed and 1 when it isn't.
To learn how to connect to the Core Unit with a computer, see page 13. For tablets, see page 15.
Press a button...

And release it!

Combining this block with blocks likefrom the Operators category

can make the same condition as anblock.

Ex.) Make the condition "if Button A is pushed":❶ Drag a[#=[#=#b]#==#b#b]

block from theOperators category into the Script Area,
then put ablock from theSensing category into its left opening.

❷ The button's value is 0 when it's beingpressed, so type 0 into the right side of theblock.

❸ Put the previous blocks into the □ of a
[もし＿なら]block from the Control category.

30

3-3-2. An Example Button Program
The following programs use all three button blocks to make a conditional program
which lights up the LED display in red for 1 second when you push the A button.

Push A

Light up red for 1 second● Using❶ Drag a[[本体のボタンが押されたときb]
本体のボタンが押されたときb][本体のボタンが押されたときb]
[本体の
[本
本体の
体のボボタタンが押押さされたときれたたとききb]b]

block from theSensing category into the Script Area.

❷ Make a program that lights up the LED display in red for one second.
See page 22 to learn how to control the LED display.

❸ Connect to the Core Unit and click the program to see how it works!

31

●

Using

or
and

are both conditional blocks, and you can either one

to program a branching condition as shown here:

Is button A
pressed?

Not Pushed

PushedLight display redfor 1 second❶ Drag a

block from the

Events category into the Script Area
to mark the start of the program.

❷ Add a [もし＿なら]❸ Put anblock from the Control category.

block into the [もし＿ならb] block.

❹ Add a program that makes the LED display light up
red for 1 second inside the [もし＿ならb] block.
See page 22 to learn how to control the LED display.

32❺ Click the program while connected to the Core Unit to see how it works!
With this program, pressing the A button won't make the LED display light
up! This is because the Core Unit runs programs incredibly fast: it checks the
A button once as soon as the program starts, and then it's done!

Check the A button

The program stops!

You can ﬁx this problem by putting the program inside of a [ずっとb] blockfrom the Control category, so it checks the A button forever!

❻ Put the whole program inside ofa [ずっとb] block from the Control category.

❼ Connect to your Core Unit and click the program to see how it works!

Reference

Using

This program does the same thing as
the one we just made!

33

Light sensor

3-4. The Light Sensor
A light sensor is a kind of sensor which measures
the brightness of its surroundings. It does this bydetecting light with a component called aphotodiode that generates electricity when lighthits it.

3-4-1. Light Sensor Programming Blocks
The light levels detected by the sensor will be displayed as numerical values on yourcomputer. You can ﬁnd the light sensor's current value by using the[本体の光センサーb][ 本体本体の光光センサー
センセンサーサー b]b]

blockfrom the Sensing category in your program. This block lets you make conditions using
the value of the light sensor.

● Checking the Light Sensor's Values❶ Connect the Core Unit to open the Sensor Board window.
To learn how to connect to the Core Unit with a computer,see page 13. For tablets, see page 15.

❷ The light sensor's value can be anywhere between 0 and 100. Try comparing
the sensor's value when you cover it with a ﬁnger and when you leave it
uncovered to see how it changes.

Bright

Dark

30-80

0-10

Surrounding Light

Sensor Board Value

There is some variation in the values detected by diﬀerent light sensors, so your results
may vary.

● To use the light sensor value to set conditions:
Combining this block with blocks likefrom the Operators category

lets you set conditions.
Ex.) Make the condition"if the light sensor's value is greater than 50":34

3-4-2. An Example Light Sensor Program
The following program uses the [本[本体の光センサーb]
本体の体の光セの光セセンササーーbb] block to set a condition which lights up
the LED display in red for 1 second when the light sensor detects darkness.
Make it darkLight up red for 1 second

Is it dark?

BrightDark

Light display redfor 1 second● Finding a ThresholdIn order for your light sensor to tell when its surroundings are dark or bright, itneeds to use a value to tell the diﬀerence between each state. Values that markboundaries between diﬀerents states like this are called threshold values. Use
the values you found on page 34 to pick a threshold value.

Bright

Dark

20

The threshold value shown above is an estimate. Pick your actual threshold based on your own results.

35

● Making the Program
Let's use the[[本体の光センサーb
本本体体の光
本体の光の光セセンンササーーb and[[#<#b]
#<
< #b
#b]

blocks together to program thecondition "if the surroundings are dark."[旗がクリックされたb][旗がク旗がクがクリッッククさされたれたb]b]b] block from the Events❶ Drag a [旗category into the Script Area to mark thestart of the program, then add an [もし＿ならb]block from the Control category below it.

❷ Drag a[[#[#<#b]#<#< b]

block from theOperators category into the[もし＿なら]□ of theblock, then put ablock from the Sensing category into its
left slot.

❸ Now make the condition "if the surroundings are dark." The value of [本[本体の光センサーb]
本体の
体の光セ
センサ
ンサーb
サーーbb]
will be less than the threshold when thesurroundings are dark, so put thethreshold value you chose on page 35 in
the slot on the right side.

Using a[#>#b]
[#>
>#
#b
b]

block as shown on the rightmakes a condition with the same eﬀect.

36

❹ Add a program that makes the LED display lightup red for 1 second inside of the [もし＿ならb] block.
See page 22 to learn how to control the LED display.

❺ Put the whole program inside of a

[ずっとb]

blockfrom the Control category.
See page 33 to learn why the[ずっとb]

block is necessary.

❻ Connect to the Core Unit and click the program to see how it works!

Reference

How LEDs Aﬀect Light Sensors

The light sensor is located next to the LED display on the Core Unit, whichmeans that if too much of the display is illuminated at once, the light sensor's
value will be aﬀected by the brightness of the LEDs. If you're using the lightsensor and the LED display in the same program, be sure to keep the eﬀects of
the LEDs' brightness in mind.

37

3-5. The Temperature Sensor
The temperature sensor is a kind of sensor whichmeasures the tempature of its surroundings. It
does this using an electrical component called a

Temperature Sensor

thermistor that changes the strength of its
electrical resistance based on its temperature.

3-5-1. Temperature Sensor Programming Blocks
You can ﬁnd the temperature sensor's current value by using the[ 本本体の温度センサー
体の温度
体の
温度セン
温度
センンサー b]b]

block from the Sensing category in your program, which lets you use that value tomake conditions for branching programs.

● Checking the Temperature Sensor's Values❶ Connect the Core Unit to open the Sensor Board window.
To learn how to connect to the Core Unit with a computer, see page
13. For tablets, see page 15.

❷ The temperature sensor's values are displayed in degrees Celsius (℃). Try
blowing air across the temperature sensor to cool it down and see how thetemperature value drops.

It cools and...

The Core Unit's built-in temperature sensor is aﬀected by heat coming from the Core Unit's own
micro-computer, so it may not always accurately measure the temperature of its surroundings.

● To set conditions using the temperature sensor:
Combining this block with blocks like[#[#>#b]#>>##b]]from the Operators category

lets you set conditions.
Ex.) Make the condition "if the temperature sensor's value is greater than 30":38

3-5-2. An Example Temperature Sensor Program
The following program uses the[本体の温度センサーb][本
本体の体の温度度センンササーーbb]]block to make a condition whichlights up the LED display in red for 1 second when the temperature sensor detectsthat its surroundings have gotten cooler.

Light up redfor 1 second

Is it cool?

Still warm

CoolerLight display redfor 1 second● What Temperature is “Cool”?
In order for your temperature sensor to tell when its surroundings are warm orcool, it needs to use a value called a threshold to tell the diﬀerence between
each state. Use the values you found on page 38 to pick a threshold value.
The program will work better if you make the threshold 2℃ below the temperature value you
found when testing.

CoolerThis threshold sets
the “cool” temperature

39

Still warm28

● Making the Program
Let's use the[[本体の温度センサーb]
[本
本体の
体の温度
の温度
温度セン
ンサー
サ bb]]

and[[#<#b][## <#<#bb]] blocks together to program thecondition "if the surroundings get cooler."❶ Drag a

block from the Events

category into the Script Area to mark thestart of the program, then add an[もし＿ならb]block from the Control category below it.

❷ Drag a

block from the Opera-[#[#<#b]#<<##b]b]tors category into theblock, then put a□of the[本体の温度センサーb]
[本
[本体の
本体体の
の温度
温度セン
センササーーb]b][もし＿なら]blockfrom the Sensing category into its left slot.

❸ Now make the condition "if the surroundings get cooler." The value of[本体の温度センサーb]
[本
本体の温度
体の温度
体の
温度セン
度セン
センササーーb]センサーb]will be less than thethreshold when the surroundings cool
down, so put the threshold value you
chose on page 39 in the slot on the rightside.

Using a[#>#b]
[#
#>
>#
#b
b]]

block as shown on theright makes a condition with the same eﬀect.

40❹ Add a program that makes the LED
display light up red for 1 second inside of
the [もし＿ならb] block.
See page 22 to learn how to control the LED
display.

❺ Put the whole program inside of ab]

block from the Control category.

See page 33 to learn why the [ずっとb] block isnecessary.

❻ Connect to the Core Unit and click the program to see how it works!

41

3-6. The Accelerometer
Accelerometers are a kind of sensor which detect tilting and shaking. Theyʼre used inmany common electronics like smartphones and game controllers.

ABC
ABC

Reference

How the Accelerometer Works

Accelerometers detect acceleration (changes in speed over a ﬁxed period oftime), measuring directional acceleration along the X, Y, and Z axes. The
accelerometer's value can be anywhere between -2.00 and 2.00.

（−）
（−）
（−）

（+）
（+）
（+）

42

3-6-1. Accelerometer Programming Blocks
There are four blocks in the Sensing category which you can use in order toprogram the accelerometer.

● To make a program start when you tilt the Core Unit:
傾いたとき b]
[ 傾いたときb]
Program blocks connected to this one will run when you tilt the Core Unit.

(Back)(Right)(Left)(Front)You can also use this block to set whether the accelerometer should detect aslight or a signiﬁcant tilt. A slight tilt is around 20°to 45°degrees, while asigniﬁcant tilt is around 45°to 90°.
Ex.) Tilting the Core Unit backward:

20°
45°

Slight tilt

43

90°

Signiﬁcant tilt

● To start a program when you shake the Core Unit:
Program blocks connected to this one will run when you shake the Core Unit.
Including shaken, this block allows you to use six orientations in order to start a
program.

LED

Reset Button● To set a condition based on tilt:
Put this block into the□ of Control category blocks like [ もし〜ならb ]to setconditions using the tilt of the accelerometer. You can choose both the direction
and amount of tilt for the condition.
Ex.) Make the condition "if signiﬁcantly tilted forward":

44

● To set a condition based on shaking:Put this block into theof Control category blocks like[ もし〜な to makeconditions which use diﬀerent accelerometer states. This block allows you tochoose from six diﬀerent accelerometer states.
Ex.) Make the condition "if the Core Unit is shaken":

Reference

Using theThe Accelerometer's Values[ 本体の加速度センサー ]or[ 傾 き の 角 度 b]]blocks lets you makeconditions based on the numerical values of the accelerometer. Reading thesevalues and setting thresholds for them can be quite diﬃcult, so consider using
them for a more advanced lesson. For more information on how to use theseblocks, check out the tutorials in the Studuino:bit Software menu.

45

3-6-2. An Example Accelerometer Program
The following programs use the

[[ゆさ
[ゆ
ゆさ

and

[ゆさぶられた[ゆ
ゆさぶ
さぶらられれた

blocks to makeconditions which light up the LED display in red for 1 second when you shake theCore Unit.

Light up red for 1 second● Using [ゆ[ゆさぶられたときb]
ゆさぶられたときb][ゆさぶられたときb]
ゆさぶ
さぶられれたとたとききbb] block from the❶ Drag a [ゆSensing category into the Script Area.

❷ Make a program that lights up the LED
display in red for 1 second.
See page 22 to learn how to control the LED
display.

❸ Connect to the Core Unit and click the program to see how it works!

46

● UsingThe[ゆさぶられてい
[ゆ
ゆさぶ
さぶられ
ぶられ
られてい
られてい
てい block is used to set up conditions, so to use it you need to make abranching program, like this:Is the Core Unit
shaking?
ShakingLight display redfor 1 second[旗がクリ
旗がクリリッッククされ旗がされたたbb block from the Events❶ Drag a [旗がクリックされたb
category into the Script Area to markthe start of the program.

❷ Add an

[もし＿ならb] block from theControl category.

❸ Putfrom the Sensing

category in the [もし＿ならb]47

block's □ .

Not Shaking

❹ Add a program that makes
the LED display light up redfor 1 second inside of the[もし＿ならb]block.

❺ Put the whole program inside of a
[ずっとb]

block from theControl category.
See page 33 to learn why the[ずっとb] block is necessary.

❻ Connect to the Core Unit and click the program to see how it works!

48

4. Using Electronic Parts
To use electronic parts to build robots, ﬁrst you need to connect your Core Unit to the
Robot Expansion Unit. DC Motors and IR Photoreﬂectors are the only electronic parts
we'll be discussing in this book.
Connecting the Robot Expansion Unit

Core Unit

The Core Unit can beconnected facing
the opposite direction
as well.

Robot Expansion Unit

Electronic Parts● DC Motor49● IR Photoreﬂector

４-1. Port Settings for the Robot Expansion Unit
The port settings in the software show which parts are connected to which ports the
Robot Expansion Unit. Whenever you program parts connected to the Robot
Expansion Unit, you need to go to Port Settings and make sure that the right parts
have been selected.

❶ Plug in the parts you're using, thenstart up the Studuino:bit Softwareand select Port Settings from theEdit menu.

❷ Select the connected parts, then click the OK button at the bottom right.

IR Photoreﬂector Ports

DC Motor Ports

Click here when you're done!

Now you'll be able to use blocks that control the parts you've set for each port.
● DC Motor Blocks● IR Photoreﬂector Blocks

50

4-2. DC Motors
You can program a DC Motor spin in a certain direction ata certain speed.

4-2-1. Connecting DC Motors
Connect a DC Motor to port M1 on the Robot Expansion Unit, then set your ports.
DC Motors can also be connected to port M2.

❶ Connect the Robot Expansion Unit to the Core Unit, then plug a DC Motor
into port M1 on the Robot Expansion Unit.

M1❷ Plug the Battery Box into the Robot Expansion Unit.

BATT

Make sure the Battery Box is plugged into the port on the Robot Expansion Unit
when you're running DC Motors.

51❸ Select Port Settings from the Edit menu in the Studuino:bit Software andset port M1 to DC motor.

DC Motor Ports

Click here when you're done!

4-2-2. DC Motor Programming Blocks
DC Motors can be programmed to spin at speciﬁc speeds and in speciﬁc directions. If
either of these isn't speciﬁed in the program, the motor won't move! You also need to givea command in the program when you want to make a DC Motor stop. There are threekinds of blocks in the Motion category which you can use to program DC Motors.
To learn how to connect to the Core Unit with a computer, see page 13. For tablets, see page 15.

● To set a DC Motor's speed:

[[DC
DC モ
モーターの速さ
ーターの速さ bb]]This block sets how fast a DC Motor spins. The larger the number set in thisblock, the faster the speed.
Smallest
０20

StoppedPossible Values

Slow

If you change the speed set in a

Largest
100

Fast

[[DC
[D
DC モーターの速さ
モーターーの
モータ
のの速さ
速速さ
さ b]
b

block, you'll have to click it again to

make it take eﬀect.
The actual speed a DC Motor spins at also depends on how much power the batteries haveremaining. If your motor is moving slower even though the set speed hasn't changed, try replacing
the batteries with new ones.

52

● To set a DC Motor's direction:[[DC
DC モモーターを正転
ーターを正転 bb]]

This block can make a DC Motor spin either clockwise or counter-clockwise.
★ Clicking a[DC[[D
DC モーターを正転
モータ
ーターをーを正正転転 b]b]

block will only make a DC Motor move if you've alreadyset the motorʼs speed.

Switching between clockwise
and counter-clockwise makes
the motor reverse directions.

A DC Motor can spin in the following directions:

Clockwise

Counter-Clockwise● To stop a DC Motor:
This block stops a DC motor from spinning. You can choose how it stops the
motor by setting either brake or coast.

Applies the DC Motorʼs brakes
to make it stop immediately.

Cuts oﬀ the power to a DC

Motor, making it slowly coast
to a stop.

53

4-2-3. An Example DC Motor Program
The following program uses the[[DC
DC モモーターを止める
ーターを
ータ
ターを
ーを止める
止める b]
止め
b]

[DC
[[D
DC モーターの速さ
モータ
ーターの
ーの速さ
速さ b]
b]

,

[[DC
[D
DC モモーターを正転ータターーをを正転
正転 b]
b]

, and

blocks to make a DC Motor spin clockwise for 3 seconds.

Spins clockwisefor 3 seconds❶ Drag a[[旗がクリック[旗
旗ががククリッリック block from the Events

category into the Script Area to markthe start of the program.

❷ Add a[DCモーターの速さb]
[[D
DCモ
モータ
ーターの
ーの速さb]
速さb]
速さ

block from

the Motion category to set the DC
Motor's speed.

❸ Add a[DCモーターを正転b]
[[D
DCモ
Cモータ
ーターを
ーを正転
を正転
正転b]
b]

block

from the Motion category to make the
DC Motor spin clockwise.

54

❹ Add a[1を待つb]
[[1
1を待
を待つb
待つb
つb]

block from theControl category and set its time to 3
seconds.

[DCモ
モータ
ーターを
ーを止めるb
止めるb
止めるb] block to❺ Add a [DCモーターを止めるb]
make the motor stop spinning.

❻ Connect to the Core Unit and click the program to see how it works!

55

4-3. IR Photoreﬂectors
IR Photoreﬂectors can detect the presence of nearby
objects by bouncing rays of infrared light oﬀ of them.

4-3-1. How IR Photoreﬂectors WorkIR Photoreﬂectors are a kind of sensor which works by detecting reﬂected infrared(IR) light. Look at the front of the sensor and you'll see two small circles. The clear
circle emits rays of infrared light, while the black circle detects infrared light.
Detects infrared light

Emits infrared light

The infrared light released by the emitter bounces back oﬀ of objects in front of thesensor, making them reﬂect back to the detector. The strength of the reﬂected lightreceived by the detector is used to tell whether the object in front of the sensor isclose.

Detector

SensorEmitter

Reﬂected light

Object56

A Bit About IR Photoreﬂectors● Sunlight contains a lot of infrared light! Make sure your IR detector isn't
in direct sunlight, or it won't work correctly.

Ob je ct

Obje ct

Sunlight

Reﬂection

The sunʼs infrared light is too strong...

Reﬂection

Now the sensor can detect IR rays
reﬂected oﬀ objects in front of it!

● Dark colors like black tend to absorb light more than they reﬂect it,so the sensor will give weaker values from darker objects.

This one reﬂects...

Emitter

57

White
block

And this one absorbs!

Emitter

Black
block

4-３-２. Connecting IR Photoreﬂectors
Connect an IR Photoreﬂector to port P0 on the Robot Expansion Unit, then set yourports.
IR Photoreﬂectors can be connected to ports P0-P2.

❶ Connect the Robot Expansion Unit to the Core Unit, then plug an IR
Photoreﬂector into port P0 on the Robot Expansion Unit.
IR Photoreﬂector

P0

Sensor Cable❷ Select Port Settings from the Edit menu in the Studuino:bit Software and set
port P0 to IR Photoreﬂector.

Pick the part here!

Click here when you're done!

584-3-3. IR Photoreﬂector Programming Blocks
The strength of the infrared light your IR Photoreﬂector picks up will be displayed as anumerical value. on your computer. The[赤外線フォトリフレクタb] block from the Sensing

category retrieves these values, letting you program conditions using the values of the
IR Photoreﬂector.

● Checking IR Photoreﬂector Values❶ Connect the Core Unit to open the Sensor Board.
To learn how to connect to the Core Unit with a computer,see page 13. For tablets, see page 15.

❷ The IR Photoreﬂector's value can be anywhere between 0 and 100. Try setting
your ﬁnger at diﬀerent distances from the IR Photoreﬂector to see how thisaﬀects the sensor's values.
Close to the sensor...

And far away!

30-50

0-10

Finger Position

Sensor Board
Value

There is some variation in the values detected by diﬀerent IR Photoreﬂectors, so the values
you ﬁnd may be diﬀerent from these.

● To set a condition using the IR Photoreﬂector:
Combining this block with blocks like[[#>#b]#>#>#b#b] from the Operators category lets

you set conditions using the IR Photoreﬂector.
Ex.) Make the condition "if the IR Photoreﬂector's value is greater than 50":59

4-3-4. An Example IR Photoreﬂector Program
The following program uses the[赤外線フォトリフレクタb]

block to set a condition whichlights up the LED display in red for 1 second when you place a ﬁnger close to the IR
Photoreﬂector.

Finger nearby

Light up red for 1 second

Is the ﬁnger close?

Far away

Close

Light display redfor 1 second● Finding a ThresholdIn order for your IR Photoreﬂector to tell when an object is close to it or not, itneeds to use a value called a threshold to tell the diﬀerence between each state.
Use the values you found on page 59 to pick a threshold value.

0

Finger is far away

ThresholdFinger is close

100

20

60

● Making the Program
Let's use the[赤外線フォトリフレクタb]

and[[#>#b]#>>##bb] blocks together to program thecondition "if there's a ﬁnger close by."❶ Drag a[[旗がクリック
[旗がク
[旗
旗がク
がクリッ
リック block from the Events

category into the Script Area to mark thestart of the program, then add an [もし＿ならb]block from the Control category below it.

❷ Drag a

block from the Opera-[#[[#>#b]#>>##bb]]

tors category into theblock, then put an□ of the[もし＿なら][赤外線フォトリフレクタb]

blockfrom the Sensing category into its left slot.

❸ Now make the condition "if there's a ﬁnger
close by." The value of[赤外線フォトリフレクタb]

will be larger than the threshold when you
put your ﬁnger close to the sensor, so put
the threshold value you chose on page 60 in
the slot on the right side.

Using a

[#<#]
[#
#<
<#
#]

block as shown on the rightmakes the same condition.

61❹ Add a program that makes the LED display
light up red for 1 second inside of the [もし＿block.
See page 22 to learn how to control the LED
display.

❺ Put the whole program inside of a

[ずっとb]

block from the Control category.
See page 33 to learn why the[ずっとb]

block isnecessary.

❻ Connect to the Core Unit and click the program to see how it works!

Reference

Detecting Black and White with an IR Photoreﬂector

As discussed on page 57, black objects will absorb infrared light, making thereﬂections IR Photoreﬂectors pick up from them weaker. Light reﬂecting oﬀ ofwhite objects, however, is much strong. This fact means you can use an IR
Photoreﬂector to distinguish between black and white!

A black object...

And a white one!

62

Unauthorized reproduction anddistrib ution prohibited

83164 ArtecRobo 2.0 Elementary Programming Fundamentals K0921

63