0% found this document useful (0 votes)
13 views3 pages

Robotics Reviewereibann0

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Robotics Reviewereibann0

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Robotics Reviewer

1. void set-up (){} – a function that runs the 2. SLEEP COMMAND


once.
use to set duration of a command in
2. void loop (){} – a function that runs the millisecond.
program
*The robot will move forward for 1000
infinitely or over and over
millisecond or
FOR () / Parenthesis
1 second then stop.
The open and close parenthesis in a function
is used to instruct statements / commands in
sleep(duration in millisecond);
braces in sleep(1000);
order to do or repeat operation following the
number of cycles required.

Open and Close Braces TURN MOVEMENTS


The open and close braces determine the 3 DIFFERENT TURNS
beginning and end of a function.
Curve Turn – 1 motor is moving faster
than the other motor.

BASIC MOVEMENTS Example: motor (1,100);

FORWARD / BACKWARD motor (2,30);

motor (motor number, speed); Shortcut: fd2(speed of M1,speed of M2);

Example: fd2(100,30);

motor(1,100); Pivot Turn – a kind of curve turn wherein


1 motor is moving forward and the other
motor(2,100); is at rest.
Example: Backward movement Example: motor (1,100);
motor(1,-100); motor( 2,0);
motor(2,-100); Shortcut: tl(100);
* 100 is the maximum speed of the motor. - turn left
* Negative speed (-100) means moving tr(100);
the opposite
- turn right
direction.
Spin Turn – both motors have the same
Using shortcut commands: speed, but 1 motor is moving the opposite
fd(100); - forward direction

bk(100); - backward Example: motor (1,100);


motor (2,-100);

©eibamn0
Robotics Reviewer
Shortcut: sl(100); - variable value/sensor value
- spin left
OBJECT
sr(100);
DETECTION
- spin right A. In your c-robot simulator, click
on the ZX SETTING icon
B. Select the sensor port PA8 To
SENSOR enable the distance sensor,
click Apply and OK.
CALIBRATION
C. Calibrate your distance sensor
1. DISPLAYING TEXT AND NUMBERS IN PA8.
THE LCD SCREEN D. Define your variable and
sensor.
lcd(“text”);
E. Create the robot’s initial
Example: movement.
lcd(“REGION 1”); F. Set the condition.
*The c-robot simulator LCD can only *Using if/else statement.
display 36 words or 18 words per row.
If/else statement executes a code
DISPLAYING SENSOR VALUE IN THE LCD if a specified condition is true or false.
SCREEN
“If”
A. In your c-robot simulator, click on
the ZX SETTING icon – condition is TRUE
B. Select the sensor you want to “else”
calibrate.
Example: PA8 – condition is FALSE
C. Create your calibration codes
and run the program. G. Define the action code of the
Sample Calibration code: if/else statement.
int sense = analog(8); F. Compile and run the program.
lcd (“%d”, sense);
*The robot must stop from moving
int once it
- a data type used to define detects the ball.
numeric variables holding whole
number *The command keep_up() is used
a to grab or carry the ball while
- variable name/ user define keep_down() is used to
analog(8) - analog port of the release the ball.
sensor you want to calibrate. (ex.,
PA8)
%d

©eibamn0
Robotics Reviewer

LINE 1. Create the Basic Following


Program
FOLLOWING
2. Determine the intersections.
Loadd map 03
*Both LEFT and RIGHT sensor
1. Click on the ZX Setting icon and detect
select your preffered sensor.
BLACK at the same time.
*Try to select PA0 and PA4
*Check on the VISIBLE POINT ON
ROBOT
to make the position of the sensor Int count = 0;
visible in your GLOBAL VARIABLE
robot. You may choose your It is a variable defined outside a
desired color of the
function. It has a global scope
visible point. means
2. Calibrate your sensors. it holds its value throughout the
*In this calibration code, we use program.
“left” as variable name for the left 4. Create conditional statement for
sensor in Port intersection.
Analog 0, and
“right” as variable name for right
sensor in Port
Analog 4
*Observe and remember the value
for each of the sensors. The value of the IR
sensor must be 1024
if placed in the White surface, and
0 if in the black line/surface.

LINE
FOLLOWING WITH
INTERSECTION
Load Map 05

©eibamn0

You might also like