pxt-ev3/docs/coding/cruise-control-2.md
2018-02-19 07:35:08 -08:00

342 B

Cruise Control Activity 2

let speed = 0;
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
    if (speed < 100)
        speed = speed + 10;
    motors.largeBC.run(speed);
}) 
sensors.touch2.onEvent(ButtonEvent.Pressed, function () {
    if (speed > -100)
        speed = speed - 10;
    motors.largeBC.run(speed);
})