Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void touchsensorHandler(touchsensor.TouchSensorUpdate notification)
- {
- if (notification.Body.TouchSensorOn)
- {
- if (spotlightOn)
- {
- _nxtLightSensorPort.Spotlight(false);
- }
- else
- {
- _nxtLightSensorPort.Spotlight(true);
- }
- }
- }
- //it is handling the light sensor
- private void lightsensorHandler(lightsensor.Replace notification)
- {
- //measuring the intensity and storing in the intensity variable as an integer
- intensity = notification.Body.Intensity;
- //setting the spotlight on
- _nxtLightSensorPort.Spotlight(true);
- }
- //
- private void buttonsHandler(buttons.ButtonsUpdate notification)
- {
- //
- }
- private void locateBlackLine(int angle)
- {
- go(0);
- for (int i = angle; i < 0; i -= 10)
- {
- turn(false, 10);
- if (intensityReading() < 45)
- {
- return;
- }
- }
- for (int i = -2*angle; i > 0; i += 10)
- {
- turn(true, 10);
- if (intensityReading() < 45)
- {
- return;
- }
- }
- }
- private int intensityReading()
- {
- /*string color = null;
- // set color string by appropriate intensity range
- if (intensity > 65)
- color = "White";
- else if (intensity < 45)
- color = "Black";
- else
- color = "Grey";
- LogInfo(LogGroups.Console, "Intensity: " + intensity + " | Color: " + color);
- */
- return intensity;
- }
- /*
- private void go(float power)
- {
- drive.SetDriveRequest request = new drive.SetDriveRequest();
- request.LeftPower = power;
- request.RightPower = power;
- _nxtDrivePort.DriveDistance(request);
- }
- */
- private void go(float power)
- {
- gendrive.SetDrivePowerRequest request = new gendrive.SetDrivePowerRequest();
- request.LeftWheelPower = power;
- request.RightWheelPower = power;
- _nxtGenDrivePort.SetDrivePower(request);
- }
- /*
- private void turn(bool direction, int angle)
- {
- drive.SetDriveRequest request = new drive.SetDriveRequest();
- if (direction == 0) angle = -angle;
- request.Degrees = angle;
- _nxtDrivePort.RotateDegrees(request);
- }
- */
- private void turn(bool direction, int angle)
- {
- gendrive.RotateDegreesRequest request = new gendrive.RotateDegreesRequest();
- if (direction == false) angle = -angle;
- request.Degrees = angle;
- _nxtGenDrivePort.RotateDegrees(request);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement