Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

NILE EGYPTIAN SCHOOLS

Grade 8 worksheet 5

What are variables and constants?


A Constant is a computer name that store value in computer's
memory and that value cannot be changed

A variable is a computer name that store value in computer's


memory and that value can be changed

What 's branching charts


Branching is a programming technique that performs one action and
ignores the other based on condition.

To understand branching,
consider the following
examples:

Example
We want to test if a number
is odd or even. To
accomplish this, we draw a
flowchart following the
steps given in the algorithm.
This flowchart is shown in
Figure.
Branching in scratch

If () Then, Else (block)


In programming, a very important part is checking conditions. In
Scratch, this is done with the if () block. In this example if the
condition is true move the sprite to right if it false move the sprite
to left:

• Doing the opposite action of the first


action if the condition is false

• If a Sprite's health is below a certain


amount, it dies, otherwise it sends a
message named attack

Page 2 of 6
• Easy script changes — if a variable equals a certain value, one thing
happens, and if the variable does not equal the value, a different
thing happens

Identifying the important blocks used in NXT

Output blocks
1-Motor(move)
2-Sound
3- Display
4-Send message
5-Color lamp
6- Lamp

Page 3 of 6
Input blocks (senseors)
1-Touch
2-Sound
3- Light
4-Ultra sonic
5-NXT buttons
6- Rotation sensor
7- Timer
8- Receive message
9- Temperature
10-Color
What are NXT Sensors?
Sensors are input devices that collect and gather physical
data surrounding us, send data to computer
Touch Sensor
The Touch Sensor gives your robot a sense of
touch. The Touch Sensor detects when it is being
pressed by something and when it is released
again.

Sound Sensor
The Sound Sensor can detect both decibels [dB]
and adjusted decibel [dBA]. A decibel is a
measurement of sound pressure.

Page 4 of 6
Light Sensor
The Light Sensor is one of the two sensors that give
your robot vision [The Ultrasonic Sensor is the other].
The Light Sensor enables your robot to distinguish
between light and dark. It can read the light intensity
in a room and measure the light intensity of colored
surfaces.

Ultrasonic Sensor

The Ultrasonic Sensor is one of the two sensors that give your robot “vision”
[The Light Sensor is the other]. The Ultrasonic Sensor enables your robot to
see and detect objects. You can also use it to make your robot avoid
obstacles, sense and measure distance, and
detect movement.

The Ultrasonic Sensor measures distance in


centimeters and in inches. It is able to measure
distances from 0 to 255 centimeters with a
precision of +/- 3 cm.

Servo Motor / Rotation Sensor

Each motor has a built-in Rotation Sensor. This


lets your control your robot’s movements
precisely.

Page 5 of 6
Flow blocks
1-Wait
2-Loop
3- Switch
4-Stop

Page 6 of 6

You might also like