Program 1 (Fall 2025) - Colortest.js
The code below is a set of functions, variables, constants, and algorithms that are the work of RoboCatz for the Fall 2025 season.
// Program name: Colortest.js
const pi = 3.141592653589793238462643382
let gearRatio = 28/20
wheelDiameter = 8.8
let degreesPerCentimeter = 360/(wheelDiameter*pi)
distanceBetweenWheels = 13.5
wheelCircumference = wheelDiameter * pi
pointTurnCircumference=distanceBetweenWheels*pi
function liftArm (degrees) {
beep()
acceleration = degrees*.1
atTopSpeed = degrees*.8
deceleration = degrees*.10
//alert('work')
resetEncoder(D)
setMotor(D,-100)
//stepMotor( D, -100 ,acceleration, atTopSpeed, deceleration)
//alert ('now')
waitHereWhile getMotorSpeed(D) == 0
waitHereUntil abs(encoderValue(D) ) >90 or isMotorStalled( D )
stopAllMotors(true)
}
function moveForward (distance) {
acceleration =gearRatio* degreesPerCentimeter * distance*.1
atTopSpeed =gearRatio* degreesPerCentimeter * distance*.8
deceleration = gearRatio* degreesPerCentimeter * distance*.1
await stepMotors( B , C , -50 ,acceleration, atTopSpeed, deceleration)
stopAllMotors(true)
}
function moveBackward (distance) {
acceleration =gearRatio* degreesPerCentimeter * distance*.1
atTopSpeed =gearRatio* degreesPerCentimeter * distance*.8
deceleration = gearRatio* degreesPerCentimeter * distance*.1
await stepMotors( B , C , 50 ,acceleration, atTopSpeed, deceleration)
stopAllMotors(true)
}
function voyageForward() {
syncMotors( B , C , -80 , min( 45, max( -45, gyroSensor()*-4)) )
}
function doYellowMission(){
moveForward(88)
liftArm(100)
moveBackward(95)
alert("go voyage")
resetGyroSensor()
sleep(100)
while(touchSensorPressed()==false){
voyageForward()
}
}
//moveBackward(100)
forever{
clearScreen()
x = colorSensorValue()
drawText( 10, 40, 'Red: ' + x.r + ' ', 2 ) // Display the value for red
if x.r>40 {
drawText(0,70, "I'm on the yellow mission")
sleep(100)
if touchSensorPressed() doYellowMission()
}
}