Incrementally increase the brightness of an RGB LED.
Create a variable brightness to store a value and then continuously set the RGB LED A brightness to its value. Every time Button A is pressed, incrementally increase the variable by 4 units, and constrain it so that its value doesn't go over 100.
input.onButtonPressed(Button.A, function () {
    position = Math.constrain(position + 4, 0, 100)
})
let position = 0
position = 0
basic.forever(function () {
    sb.setServoPosition(sb.servo(SBServo.ServoA), position)
})If using micro:bit for the first time, follow this setup.