ea956f1a73
* renaming up/down/click to released/pressed/bump * missing images * fixing signature issue * updated strings * white lego logo
527 B
527 B
Cruise Control Activity 3
let speed = 0
function decelerate() {
if (speed > -100) {
speed = speed - 10
}
}
function accelerate() {
if (speed < 100) {
speed = speed + 10
}
}
function update() {
brick.clearScreen()
brick.showString("speed: " + speed, 1)
motors.largeBC.setSpeed(speed)
}
sensors.touch2.onEvent(ButtonEvent.Pressed, function () {
accelerate()
update()
})
sensors.touch1.onEvent(ButtonEvent.Pressed, function () {
decelerate()
update()
})