| This article might contain obsolete information. Please do not follow the instructions in this page if you are a student.
If you are a PiE staff, consider updating the information on this page and then removing this warning.
This is the class you use to control the Polar Bear Motor Controller.
//IMPORTANT //How fast the motor goes. 100 is full forward, -100 is full backwards, 0 is stopped. //The motors will not move if motorBrake is non-zero. motorSpeed //Edit this if you want the motor to brake; it is mostly used in Autonomous mode. //Default is 0. 0 is no braking, 10 is maximum braking //If motorBrake is non-zero, then motorSpeed should be 0 motorBrake //This field controls how fast your motor brakes when inside of the brake range, initially 0 //Has a range from 0 to 255; 0 is full coast, and 255 is full brake //Change this depending on whether you want your robot to coast or not brakePower //Changing this field creates a range in which your joystick will brake //Only use this if you have a joystick that doesn't have good springs and won't return all the way to 127 //Use piemos to find out how much is off then set this to how much it is greater than or less than 127 brakeRange
Methods to use:
KillActuators(); //stop motors and make it so they can't drive ReviveActuators();//make motors drive-able again
If you call robot.KillActuators or robot.ReviveActuators it will apply the method to all actuators
Methods not to use:
How to Use
I2CMotorController i2c = new I2CMotorController(Robot Robo, ushort deviceAdd);
ushort deviceAdd in form 0x0A, drive motors should be 0x0A and 0x0B, non-drive motors should be 0x0C, 0x0D, and all other addresses.
For Tank Drive
i2c1.motorSpeed = ((float)(robot.UIAnalogVals - 128) * 100 / (float)128); i2c2.motorSpeed = -1*((float)(robot.UIAnalogVals - 128) * 100 / (float)128);
i2c1 is right motor and i2c2 is left motor.
Make it brake in Autonomous
Change how fast it brakes
Change this if you have a bad joystick
What to use it for
Controlling the Motors