pxt-ev3/docs/coding/cruise-control-2.md
2018-01-05 21:49:04 -08:00

362 B

Cruise Control Activity 2

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