The Brain One is a basic analogue controller device. It has
an electrical circuit which reverses the directions of
the connected motors for a small period of time whenever one of the
sensors connected to the motor is triggered.
IO Port configuration:
0 and 1 - inputs from sensors (0 - left, 1 - right)
2 through 5 - outputs (must be connected directly to the locomotion)
protected var leftDelay:Number
protected var leftPort:IOPort
protected var leftTimer:Number = 0
protected var rightDelay:Number
protected var rightPort:IOPort
protected var rightTimer:Number = 0
public function BrainOne(ld:Number, rd:Number)
Creates a Brain One with the timers connected to the
left and right motors set to the number of seconds provided.
NOTE: using timers of slightly different values will help
the robot to avoid getting stuck in on place whenever it's
movement is perpendicular to the edge of the surface.
Parameters
| ld:Number — - left timer (in seconds)
|
| |
| rd:Number — - right timer (in seconds)
|
protected function leftWheelForward():void
protected function leftWheelReverse():void
protected function rightWheelForward():void
protected function rightWheelReverse():void
public function setTimers(ld:Number, rd:Number):void
Set the values of the Brain's timers to the provided ones
Parameters
| ld:Number — - left timer (in seconds)
|
| |
| rd:Number — - right timer (in seconds)
|
public function step():void
A function that is called on every step of the physics engine.
It advances the timers and reverses the motors whenever needed.
public static const LEFT_SENSOR_PORT:Number = 0
public static const RIGHT_SENSOR_PORT:Number = 1