Program 3 (Fall 2022)
The code below is a set of functions, variables, constants, and algorithms that are the work of RoboCatz for the Fall 2022 season.
//
//
function driveForward(inches,powerLevel=80){
resetEncoder(B)
syncMotors(B,C,powerLevel)
waitHereWhile abs(encoderValue(B))<50*inches
stopAllMotors(true)
}
function pointTurn(){
syncMotors( B, C, 10, 200 )
resetGyroSensor()
until gyroSensorValue() > 45 {
clearScreen()
drawText(10, 10, gyroSensorValue(),2)
}
stopAllMotors(true)
}
function findLine(){
syncMotors( B, C, 30 ) // Start moving
while( lightSensorPct() > 30 ) { // while the light sensor sees a white ground
drawText(50, 60, lightSensorPct(), 2) // Show the lightSensor Percentage
sleep(100) // sleep for 1/10th of a second
} // repeat the loop
stopAllMotors() // line has been detected
}
driveForward(17)
findLine()
driveForward(2,30)
pointTurn()