Programming in RobotCIntroduction to
Installing RobotChttp://robotc.net/3.0 MindstormsLicense ID: 60857910Password: S9WY95
Setting Menu LevelOpen Up the Advanced Options
Connecting Bluetooth
Connecting Bluetooth
Connecting Bluetooth1234
Connecting Bluetooth
Connecting Bluetooth
Sample ProgramsRobotC: File -> Open Sample ProgramSay Watt: http://github.com/SayWatt
First ProgramLet’s make the robot move!task main() {	motor[leftMotor] = 100;	motor[rightMotor] = 100;	wait1Msec(2000);	motor[leftMotor] = 0;	motor[rightMotor] = 0;}
task main() {Tells RobotC:  Start Here!
motor[leftMotor] = 100;motor[rightMotor] = 100;Make leftMotor andrightMotor go forwardat full speed.
wait1Msec(2000);Wait 2000 milliseconds.(2 seconds)
motor[leftMotor] = 0;motor[rightMotor] = 0;Make leftMotor andrightMotor stop.
}Tells RobotC: We’re done.
Up Next: Touch Sensortask main() {	motor[leftMotor] = 100;	motor[rightMotor] = 100;	while(SensorValue(touch) != 1) {		wait1Msec(50);	}	motor[leftMotor] = 0;	motor[rightMotor] = 0;}
while(SensorValue(touch) != 1) {Checks this“Keep looping through thisuntil the value of‘touch’ equals 1.”
What’s Next?Try to make these changes:Move backwards for 2 sec.	after the button is pressed.Try turning around and going	the other way.
Light Sensortask main() {  motor[leftMotor] = 100;  motor[rightMotor] = 100;  while(SensorValue(light) <= 45) {    wait1Msec(50);  }  motor[leftMotor] = 0;  motor[rightMotor] = 0;}
Functions
Basic Functionsvoid startMotors() {  motor[leftMotor] = 100;  motor[rightMotor] = 100;}void stopMotors() {  motor[leftMotor] = 0;  motor[rightMotor] = 0;}
Passing Valuesvoid setMotors(int speed) {  motor[leftMotor] = speed;  motor[rightMotor] = speed;}Examples:orsetMotors(100);setMotors(0);
Light Sensor FunctionTrue / FalseboolcheckLightSensor() {  if(SensorValue(light) <= 45) {    return true;  }else {    return false;  }}
Line FollowingUse the light sensorto follow a whiteline.
Joysticks
3.00 Joystick BugOpen the JoystickDriver.cChange line 123 to:const intkMaxSizeOfMessage = 19;
Analog Sticksjoystick.joy1_y1;joystick.joy1_x1;joystick.joy1_y2;…..
ButtonsReturns a bool.joy1Btn(1);joy1Btn(2);…
Basic Joystick Codetask main() {  while(true) {getJoystickSettings(joystick);    motor[leftMotor] = joystick.joy1_y1;    motor[rightMotor] = joystick.joy1_y2;    wait1Msec(20);  }}
“Joystick Drift”
Fixing DriftintleftMotorValue = joystick.joy1_y1;intrightMotorValue = joystick.joy1_y2;if(abs(leftMotorValue) < 20) {leftMotorValue = 0;}if(abs(rightMotorValue) < 20) {rightMotorValue = 0;}
Wait For Start

Introduction to RobotC