2020-09-08 11:04:25 +02:00
|
|
|
# Simulator
|
|
|
|
|
|
|
|
The JavaScript simulator allows you to test and execute most BBC micro:bit programs in the browser.
|
|
|
|
It allows you to emulate sensor data or user interactions.
|
|
|
|
|
|
|
|
```sim
|
2022-04-26 19:28:42 +02:00
|
|
|
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
|
2020-09-08 11:04:25 +02:00
|
|
|
basic.showString("A");
|
|
|
|
});
|
2022-04-26 19:28:42 +02:00
|
|
|
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
|
2020-09-08 11:04:25 +02:00
|
|
|
basic.showString("B");
|
|
|
|
});
|
2022-04-26 19:28:42 +02:00
|
|
|
input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Click, () => {
|
2020-09-08 11:04:25 +02:00
|
|
|
basic.showString("0");
|
|
|
|
});
|
2022-04-26 19:28:42 +02:00
|
|
|
input.onPinTouchEvent(TouchPin.P1, ButtonEvent.Click, () => {
|
2020-09-08 11:04:25 +02:00
|
|
|
basic.showString("1");
|
|
|
|
});
|
2022-04-26 19:28:42 +02:00
|
|
|
input.onPinTouchEvent(TouchPin.P2, ButtonEvent.Click, () => {
|
2020-09-08 11:04:25 +02:00
|
|
|
basic.showString("2");
|
|
|
|
});
|
|
|
|
input.temperature()
|
|
|
|
input.compassHeading()
|
|
|
|
input.lightLevel()
|
|
|
|
```
|