



















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This course is about robots intelligence. This lecture is one of many lectures on robots you can find in my uploads. Following key points are hint to specific topics of this lecture. Textual User Interface, Global Variables, Task Blocks, Inline Functions, Subroutines, Programs Translated, Development Environment, First Fire, Switched, Window
Typology: Slides
1 / 59
This page cannot be seen from the preview
Don't miss anything!




















































NQC Programming
If your program wonāt compileā¦
In robotC
#pragma config(Motor, motorA, RightMotor, tmotorNormal, PIDControl, ) #pragma config(Motor, motorB, LeftMotor, tmotorNormal, PIDControl, ) //!!Code automatically generated by 'ROBOTC' configuration wizard !!//
void rightTurn(int turnTime) { motor[RightMotor] = -100; motor[LeftMotor] = 100;
wait10Msec(turnTime); }
void leftTurn(int turnTime) { motor[RightMotor] = 100; motor[LeftMotor] = -100;
wait10Msec(turnTime); }
sub turn_around() { OnRev(OUT_C); Wait(400); OnFwd( OUT_A + OUT_C ); }
This in NQC
In robotC
#pragma config(Motor, motorA, #pragma config(Motor, motorB, RightMotor,LeftMotor, tmotorNormal, PIDControl, )tmotorNormal, PIDControl, ) //!!Code automatically generated by 'ROBOTC' configuration wizard !!// void rightTurn(int turnTime) { motor[RightMotor] = -100; motor[LeftMotor] = 100;
}^ wait10Msec(turnTime); void leftTurn(int turnTime) { motor[RightMotor] = 100; motor[LeftMotor] = -100;
}^ wait10Msec(turnTime);
task main() { motor[RightMotor] = 100; motor[LeftMotor] = 100; wait10Msec(100); rightTurn(20); motor[RightMotor] = 100; motor[LeftMotor] = 100; wait10Msec(100); leftTurn(20); motor[RightMotor] = 100; motor[LeftMotor] = 100; wait10Msec(100);
}^ StopAllTasks();
Subroutines
sub turn_around() { OnRev(OUT_C); Wait(400); OnFwd(OUT_A+OUT_C); }
task main() { OnFwd(OUT_A+OUT_C); Wait(100); turn_around(); Wait(200); turn_around(); Wait(100); turn_around(); Off(OUT_A+OUT_C);}c
Subroutines
be shared between several different callers (space efficient).
Control structures
Inline function, call by reference
void turn_around(int turntime) { OnRev(OUT_C); Wait(turntime); OnFwd(OUT_A+OUT_C); } task main() { OnFwd(OUT_A+OUT_C); Wait(100); turn_around(200); Wait(200); turn_around(50); Wait(100); turn_around(300); Off(OUT_A+OUT_C); }
task main() { int count=0; while (count<=5) { PlaySound(SOUND_CLICK) ; Wait(count*20); increment(count); } } void increment(int& n) { n++; }