# ROBOT C Virtual Worlds Answas
## BASIC MOVEMENT
### Moving Forward
```c=
#pragma config(Motor, motorB, leftMotor, tmotorEV3_Large, PIDControl, driveLeft, encoder)
#pragma config(Motor, motorC, rightMotor, tmotorEV3_Large, PIDControl, driveRight, encoder)
task main(){
setMotorSpeed(motorB,90);
setMotorSpeed(motorC,90);
delay(1000);
}
```
### 85 cm Challenge
```c=
#pragma config(Motor, motorB, leftMotor, tmotorEV3_Large, PIDControl, driveLeft, encoder)
#pragma config(Motor, motorC, rightMotor, tmotorEV3_Large, PIDControl, driveRight, encoder)
task main(){
setMotorSpeed(motorB,90);
setMotorSpeed(motorC,90);
delay(2100);
}
```
### Arm Control
```c=
#pragma config(Motor, motorB, leftMotor, tmotorEV3_Large, PIDControl, driveLeft, encoder)
#pragma config(Motor, motorC, rightMotor, tmotorEV3_Large, PIDControl, driveRight, encoder)
task main(){
setMotorSpeed(motorB,90);
setMotorSpeed(motorC,90);
delay(2100);
}
```
## SENSORS
### Forward Until Red
```c=
#pragma config(Sensor, S3, colorSensor, sensorEV3_Color, modeEV3Color_Color)
#pragma config(Motor, motorB, leftMotor, tmotorEV3_Large, PIDControl, driveLeft, encoder)
#pragma config(Motor, motorC, rightMotor, tmotorEV3_Large, PIDControl, driveRight, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main()
{
int red,green,blue;
getColorRGB(S3,red,green,blue);
while(red < 100){
setMotor(motorB,90);
setMotor(motorC,90);
delay(100);
getColorRGB(S3,red,green,blue);
}
setMotor(motorB,0);
setMotor(motorC,0);
delay(1000);
}
```
### Forward To Stop Line
- pointA
```c=
task main()
{
int red,green,blue;
getColorRGB(S3,red,green,blue);
while(red > 20 && green > 20 && blue > 20){
setMotor(motorB,90);
setMotor(motorC,90);
delay(100);
getColorRGB(S3,red,green,blue);
}
setMotor(motorB,0);
setMotor(motorC,0);
delay(1000);
}
```
- pointB
```c=
task main()
{
int red,green,blue;
getColorRGB(S3,red,green,blue);
while(red < 20 && green < 20 && blue < 20){
setMotor(motorB,90);
setMotor(motorC,90);
delay(100);
getColorRGB(S3,red,green,blue);
}
setMotor(motorB,0);
setMotor(motorC,0);
delay(1000);
}
```
### Traffic Lights Challange
```c=
task main()
{
int red,green,blue;
while(1){
getColorRGB(S3,red,green,blue);
if(red < 100){
setMotor(motorB,90);
setMotor(motorC,90);
delay(100);
}
else{
setMotor(motorB,0);
setMotor(motorC,0);
delay(500);
}
}
}
```
## PROGRAM FLOW
### Line Tracking
```c=
task main()
{
int black;
while(1){
black = getColorReflected(S3);
if(black > 20){
setMotor(motorB,90);
setMotor(motorC,90);
delay(100);
}
else{
setMotor(motorB,0);
setMotor(motorC,0);
delay(100);
}
}
}
```