A command to create a new button object that can be programmed in the same way as the blocks in the Circuit drawer. The var myButton = createButton() command creates a new button object named myButton that you can use in onBoardEvent()
blocks, just like buttonL
and buttonR
. Remember to pass in a pin parameter so the board knows where the button is connected.
// Create a button attached to a pin var myButton = createButton(5); // Buzz when the button goes down onBoardEvent(myButton, "down", function() { buzzer.note("G4", 100); });
var myButton = createButton(pin);
Name | Type | Required? | Description |
---|---|---|---|
Pin | number | The number of the pin your LED is connected to. This is usually printed on your board, but can also be found in your board's documentation. |
New button object
Found a bug in the documentation? Let us know at documentation@code.org