I am using Micro:bit and the code is as follows: function door (num: number) { robotbit.MotorRun(robotbit.Motors.M1A, num) basic.pause(1450) robotbit.MotorRun(robotbit.Motors.M1A, 0) } input.onButtonPressed(Button.A, function () { door(255) }) input.onButtonPressed(Button.B, function () { door(-255) }) basic.showIcon(IconNames.Heart) let time = 0 let door_open = false basic.forever(function () { if (pins.digitalReadPin(DigitalPin.P15) == 0) { time = input.runningTime() if (!(door_open)) { door_open = true door(255) } } else { if (door_open) { if (input.runningTime() - time > 5000) { door(-255) door_open = false } } } })
This AMAZING!!
Halo mau tanya
Please mention the components
I eagerly need it
Materials used:
Micro:bit, robotbit, stepper motor, bamboo stick, hose, gear rack, cardboard
por favor me puedes envair el codigo de l progrma
Plase, can you share the materias and code that you used?
I am using Micro:bit and the code is as follows:
function door (num: number) {
robotbit.MotorRun(robotbit.Motors.M1A, num)
basic.pause(1450)
robotbit.MotorRun(robotbit.Motors.M1A, 0)
}
input.onButtonPressed(Button.A, function () {
door(255)
})
input.onButtonPressed(Button.B, function () {
door(-255)
})
basic.showIcon(IconNames.Heart)
let time = 0
let door_open = false
basic.forever(function () {
if (pins.digitalReadPin(DigitalPin.P15) == 0) {
time = input.runningTime()
if (!(door_open)) {
door_open = true
door(255)
}
} else {
if (door_open) {
if (input.runningTime() - time > 5000) {
door(-255)
door_open = false
}
}
}
})
Materials used:
Micro:bit, robotbit, stepper motor, bamboo stick, hose, gear rack, cardboard