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
|
2023-01-11 18:51:27 +01:00
|
|
|
input.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Click), () => {
|
2020-09-08 11:04:25 +02:00
|
|
|
basic.showString("A");
|
|
|
|
});
|
2023-01-11 18:51:27 +01:00
|
|
|
input.onButtonEvent(Button.B, input.buttonEventValue(ButtonEvent.Click), () => {
|
2020-09-08 11:04:25 +02:00
|
|
|
basic.showString("B");
|
|
|
|
});
|
2023-01-11 18:51:27 +01:00
|
|
|
input.onPinTouchEvent(TouchPin.P0, input.buttonEventValue(ButtonEvent.Click), () => {
|
2020-09-08 11:04:25 +02:00
|
|
|
basic.showString("0");
|
|
|
|
});
|
2023-01-11 18:51:27 +01:00
|
|
|
input.onPinTouchEvent(TouchPin.P1, input.buttonEventValue(ButtonEvent.Click), () => {
|
2020-09-08 11:04:25 +02:00
|
|
|
basic.showString("1");
|
|
|
|
});
|
2023-01-11 18:51:27 +01:00
|
|
|
input.onPinTouchEvent(TouchPin.P2, input.buttonEventValue(ButtonEvent.Click), () => {
|
2020-09-08 11:04:25 +02:00
|
|
|
basic.showString("2");
|
|
|
|
});
|
|
|
|
input.temperature()
|
|
|
|
input.compassHeading()
|
|
|
|
input.lightLevel()
|
|
|
|
```
|