pxt-ev3/docs/examples/core-set/robotarm-labview.md

51 lines
1.7 KiB
Markdown
Raw Normal View History

2018-01-16 06:27:19 +01:00
# Robot Arm
```typescript
function INI() {
motors.largeB.setBrake(true)
motors.largeC.setBrake(true)
motors.mediumA.setBrake(true)
2018-02-19 16:35:08 +01:00
motors.largeB.run(-50)
2018-01-16 06:27:19 +01:00
pauseUntil(() => sensors.color3.light(LightIntensityMode.Reflected) > 25);
motors.largeB.stop();
2018-02-19 16:35:08 +01:00
motors.mediumA.run(30, 1, MoveUnit.Seconds);
motors.mediumA.run(-50, 90, MoveUnit.Degrees);
motors.largeC.run(50)
sensors.touch1.pauseUntil(ButtonEvent.Pressed);
2018-02-19 16:35:08 +01:00
motors.largeC.run(-50, 0.86, MoveUnit.Rotations);
2018-01-16 06:27:19 +01:00
}
INI()
let down = false;
forever(function () {
2018-01-16 06:27:19 +01:00
brick.showImage(images.informationQuestionMark)
brick.setStatusLight(StatusLight.OrangePulse);
2018-01-16 06:27:19 +01:00
pauseUntil(() => (down = brick.buttonDown.wasPressed()) || brick.buttonUp.wasPressed())
brick.setStatusLight(StatusLight.Off)
2018-01-16 06:27:19 +01:00
music.playSoundEffect(sounds.mechanicalAirRelease)
brick.showImage(images.informationAccept)
if (down) {
brick.showImage(images.informationForward)
2018-02-19 16:35:08 +01:00
motors.largeC.run(65, 0.85, MoveUnit.Rotations);
2018-01-16 06:27:19 +01:00
} else {
brick.showImage(images.informationBackward)
2018-02-19 16:35:08 +01:00
motors.largeC.run(-65, 0.85, MoveUnit.Rotations);
2018-01-16 06:27:19 +01:00
}
2018-02-19 16:35:08 +01:00
motors.largeB.run(20, 275, MoveUnit.Degrees)
motors.mediumA.run(30, 1, MoveUnit.Seconds)
motors.largeB.run(-55)
2018-01-16 06:27:19 +01:00
pauseUntil(() => sensors.color3.light(LightIntensityMode.Reflected) > 25);
motors.largeB.stop();
if (down) {
2018-02-19 16:35:08 +01:00
motors.largeC.run(-65, 0.86, MoveUnit.Rotations);
2018-01-16 06:27:19 +01:00
} else {
2018-02-19 16:35:08 +01:00
motors.largeC.run(65, 0.85, MoveUnit.Rotations);
2018-01-16 06:27:19 +01:00
}
2018-02-19 16:35:08 +01:00
motors.largeB.run(20, 275, MoveUnit.Degrees);
motors.mediumA.run(-30, 90, MoveUnit.Degrees);
motors.largeB.run(-55)
2018-01-16 06:27:19 +01:00
pauseUntil(() => sensors.color3.light(LightIntensityMode.Reflected) > 25);
motors.largeB.stop()
})
```