RoboCatz.com

Program 3 (Fall 2025) - Hammer2.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: Hammer2.js
function hammer(){beep()
	setMotor( D, 60 )
	while(encoderValue(D)<120)
		sleep(10)
	stopAllMotors(true)
	setMotor(D, -100)
	while(encoderValue(D)>0)
		sleep(10)
	stopAllMotors(true)
	sleep(500)
}						// hello future robocats
function setHammer(){				// are you good at coding?
	setMotor(D, -100)			// i hope so, because i wrote this a long time ago
	while(abs(encoderValue(D))<120) 	// and i want us to win
		sleep(10)			// by the way, did 2025 robocats win? probs not
	stopAllMotors(true)			// anyways the clue is backwards
	resetEncoder(D)
}

function forward( distance ){
	resetEncoder( B )
	syncMotors( B, C, -50 )
	while abs(encoderValue( B )) 0) {
	alert("positive " + gyroSensorValue())
	}
}

resetGyroSensor()
//alert(gyroSensorValue())


function moveForward() { 
		syncMotors( B , C , -80 , min( 45, max( -45, gyroSensor()*-4)) )
}


//turnBackToZ()
resetEncoder(D)
setHammer()
moveForward( 800 )

//drawCab()
sleep(1000)

hammer()
hammer()
hammer()
hammer()
hammer()
hammer()

backwards(600)