pxt-calliope/docs/device/simulator.md

25 lines
587 B
Markdown
Raw Normal View History

2016-04-16 00:40:55 +02:00
# Simulator
The JavaScript simulator allows to test and execute most BBC micro:bit programs in the browser.
It allows to emulate sensor data or user interactions.
```sim
input.onButtonPressed(Button.A, () => {
basic.showString("A");
});
input.onButtonPressed(Button.B, () => {
basic.showString("B");
});
input.onPinPressed(TouchPin.P0, () => {
basic.showString("0");
});
input.onPinPressed(TouchPin.P1, () => {
basic.showString("1");
});
input.onPinPressed(TouchPin.P2, () => {
basic.showString("2");
});
input.temperature()
input.compassHeading()
input.lightLevel()
```