pxt-ev3/docs/coding/cruise-control-2.md
Peli de Halleux ea956f1a73
Buttons rename (#287)
* renaming up/down/click to released/pressed/bump

* missing images

* fixing signature issue

* updated strings

* white lego logo
2018-01-31 08:28:00 -08:00

15 lines
352 B
Markdown

# Cruise Control Activity 2
```blocks
let speed = 0;
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
if (speed < 100)
speed = speed + 10;
motors.largeBC.setSpeed(speed);
})
sensors.touch2.onEvent(ButtonEvent.Pressed, function () {
if (speed > -100)
speed = speed - 10;
motors.largeBC.setSpeed(speed);
})
```