You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Simulator: digitalReadPin always returns 0 when pin is clicked #7093
In the simulator, clicking a pin that is being read with digital read pin no longer changes the value returned. pins.digitalReadPin() always returns 0, so programs that depend on digital input can't be tested in the simulator. See screenshot below.
In the simulator, click P0 near the bottom of the pin. The pin label shows 0.
Click P0 near the top of the pin. The pin label shows 1, but the heart never appears (see screenshot below).
Expected behavior
Clicking anywhere on the pin should set it as 1, the pin label should show 1 and the heart icon should be shown. I assume it should not have the slider effect like analogReadPin where clicking the bottom/top of pin gives a different value.
Screenshots
micro:bit version (please complete the following information):
not hardware related
Desktop (please complete the following information):
OS: Mac
Browser: Chrome
Version
Likely cause #6795 (commit a7e9261) changed the pin mouse and keyboard handlers in sim/visuals/microbit.ts so that digital input pins are capped at a value of 1:
I've been looking at this and we have some choice as to how to proceed.
Using MakeCode v7 as a reference, mouse interaction with digital pins has a tiny area at the bottom that is 0 and the rest of the pin is 1. It's a slider but perhaps not so as anyone would notice for digital pins.
#6795 has flipped this, and a tiny area at the top goes to 1. Additionally, it's not correctly mapped to the pin value so even when we show 1 in the sim the program doesn't see it.
Options:
Reinstate old interaction. Though I feel bad about such a tiny area being 0. I suspect folks are clicking to get 1 at the moment and then some folks probably get confused when trying to go back to 0. This demo just reinstates (code).
Use a larger area. 50:50 seems logical but for the big pins 50% is confusingly approx the top of the non-hole area so hard to click the top part. This demo splits the pin half way through the main pad (code). Because it doesn't look like a slider it's still easy to click the bottom half and assume it doesn't do anything. I find it hard to recommend.
Change approach for digital pins. This pin uses a switch for a11y and clicking toggles the pin value. This makes a lot of sense for a digital pin. This demo takes the toggle approach (code). Tested in VoiceOver and NVDA. I think this is the most natural approach.
Richard Knoll (@riknoll) I've opened a PR to cherry-pick this fix to stable9.0 as it would be great to get this fix live to address the user feedback we've had. If the PR doesn't match convention, please feel free to close it and handle porting the change independently if convenient. Thanks!
Activity
abchatra commentedon Oct 1, 2026
Robert Knight (@microbit-robert) ?
microbit-matt-hillsdon commentedon Oct 2, 2026
We'll take a look at this one. Please can you assign to me?
martinwork commentedon Oct 12, 2026
Also reported in https://support.microbit.org/helpdesk/tickets/103321 (private).
martinwork commentedon Oct 26, 2026
Also reported in https://support.microbit.org/helpdesk/tickets/103630 (private)
martinwork commentedon Oct 30, 2026
Also reported in http://support.microbit.org/helpdesk/tickets/103593 (private)
Fix sim digitalReadPin and restore previous pin click areas
Fix sim digitalReadPin and make digital pins toggle switches
Fix sim digitalReadPin and split digital pin click areas in half
microbit-matt-hillsdon commentedon Oct 30, 2026
I've been looking at this and we have some choice as to how to proceed.
Using MakeCode v7 as a reference, mouse interaction with digital pins has a tiny area at the bottom that is 0 and the rest of the pin is 1. It's a slider but perhaps not so as anyone would notice for digital pins.
#6795 has flipped this, and a tiny area at the top goes to 1. Additionally, it's not correctly mapped to the pin value so even when we show 1 in the sim the program doesn't see it.
Options:
Richard Knoll (@riknoll) Abhijith Chatra (@abchatra) appreciate your thoughts. Whatever we do we'll need a fix to live.
riknoll commentedon Oct 30, 2026
i vote for toggle! slider doesn't really make any sense
microbit-matt-hillsdon commentedon Nov 3, 2026
Thanks Richard Knoll (@riknoll). Discussed with Jonny too and we're happy with that approach. I've opened #7117.
Fix sim digitalReadPin and make digital pins toggle switches (microso…
microbit-robert commentedon Nov 5, 2026
Richard Knoll (@riknoll) I've opened a PR to cherry-pick this fix to stable9.0 as it would be great to get this fix live to address the user feedback we've had. If the PR doesn't match convention, please feel free to close it and handle porting the change independently if convenient. Thanks!