The snap:bit is an electronic component for the Snap Circuits educational electronic kit. It features a socket for connecting the BBC micro:bit. This allows the Snap Circuits to be programmatically controlled by the micro:bit.
This project is similar to the Connect Press Switch to Micro:bit project that demonstrates how to properly connect the Press Switch (S2) part of Snap Circuits to the snap:bit board. Here, the difference is that instead of triggering an "on pin pressed" event, pressing the button would trigger an "on button pressed" event. This is the same event triggered by pressing button A or button B of the BBC micro:bit.
This way, the Press Switch (S2) can be used to conveniently duplicate the onboard buttons of the BBC micro:bit, while keeping P0, P1, and P2 of the snap:bit board free for connecting other Snap Circuits parts.
CodeYou can build the code yourself in the MakeCode Editor. You will find the "on pin pressed" block under the Input section.
Alternatively, open the ready project here: https://makecode.microbit.org/#pub:_RtVYHaJedXXt
Once ready, download the code to your micro:bit. Then disconnect all cables from your micro:bit. Both the USB and the battery pack must be disconnected from the micro:bit.
Duplicating the onboard button ABuild the circuit shown in the diagram above.
The 21-pin breakout board from the snap:bit extension kit must be plugged into the snap:bit board. The BBC micro:bit must be plugged into the 21-pin breakout board. The red snap-to-female wire must be connected to pin P5 of the 21-pin breakout board.
When you close the slide switch (S1), the Battery Holder (B1) powers the snap:bit through the 3V snap and the micro:bit turns on.
Press the press switch (S2) and release it within 1 second. This closes the circuit between the P5 and GND pins of the micro:bit. Pin P5 is wired directly to the micro:bit's onboard A push button. Connecting P5 to GND triggers the “on button A pressed” event the micro:bit now displays an arrow pointing to the onboard button A.
Duplicating the onboard button BChange the previous diagram by replacing the red snap-to-female wire with the green snap-to-female wire that must be connected to pin P11 of the 21-pin breakout board.
Now, pressing the press switch (S2) closes the circuit between the P11 and GND pins of the micro:bit. Pin P11 is wired directly to the micro:bit's onboard B push button. Connecting P11 to GND triggers the “on button B pressed” event the micro:bit now displays an arrow pointing to the onboard button B.
Duplicating the onboard button A+B (not a good idea)Change the previous diagram by connecting both the red and green snap-to-female wires to pins P5 and P11 of the 21-pin breakout board, respectively.
Now, the press switch (S2) is connected to both P5 and P11. Pressing it would connect both P5 and P11 to GND, which triggers the “on button A+B pressed” event. The micro:bit now displays the "X" icon.
While this is a very convenient way to press both A and B onboard buttons together, this disables the ability to separately press the onboard buttons. You can check this by trying to press either the onboard button A or the onboard button B of the micro:bit. The reason for this limitation is that we actually wired pins P5 and P11 together. Connecting any of them to GND (by pressing an onboard button) will actually connect both of them to GND, simulating the A+B button press.
Thus, this last diagram is not a good idea to implement because we lose the ability to separately press the onboard buttons.
Comments