Skip to content

Fix sim digitalReadPin and make digital pins toggle switches - #7117

Merged
Richard Knoll (riknoll) merged 2 commits into
microsoft:masterfrom
microbit-matt-hillsdon:sim-digital-pin-switch-role
Nov 3, 2026
Merged

Richard Knoll (riknoll) merged 2 commits into
microsoft:masterfrom
microbit-matt-hillsdon:sim-digital-pin-switch-role

Conversation

@microbit-matt-hillsdon

Copy link
Copy Markdown
Contributor

#6795 limited digital input pins to values 0/1 for keyboard and screen reader support, but digitalReadPin still required a value above 100, so it always returned 0. The new click mapping also meant that only the top of the pin set it high, which on the small edge pins was under 10% of the pin's height.

Read a digital pin as high for any value above 0, matching how the pin is displayed.

Clicking a digital input pin now toggles it between 0 and 1, wherever on the pin it is clicked. To match, digital pins are exposed to assistive technology as role="switch" with aria-checked rather than as a 0-1 slider, and Space and Enter toggle them. Arrow keys still work.

The toggle happens on click rather than pointerdown so that screen readers in browse mode, which activate a switch by dispatching a click, can toggle it. Analog pins remain sliders and touch pins remain buttons.

Fixes #7093

microsoft#6795 limited digital input pins to values 0/1 for keyboard and screen
reader support, but digitalReadPin still required a value above 100, so
it always returned 0. The new click mapping also meant that only the
top of the pin set it high, which on the small edge pins was under 10%
of the pin's height.

Read a digital pin as high for any value above 0, matching how the pin
is displayed.

Clicking a digital input pin now toggles it between 0 and 1, wherever
on the pin it is clicked. To match, digital pins are exposed to
assistive technology as role="switch" with aria-checked rather than as
a 0-1 slider, and Space and Enter toggle them. Arrow keys still work.

The toggle happens on click rather than pointerdown so that screen
readers in browse mode, which activate a switch by dispatching a click,
can toggle it. Analog pins remain sliders and touch pins remain
buttons.

Fixes microsoft#7093

@riknoll Richard Knoll (riknoll) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@riknoll
Richard Knoll (riknoll) added this pull request to the merge queue Nov 3, 2026
Merged via the queue into microsoft:master with commit 7701f26 Nov 3, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simulator: digitalReadPin always returns 0 when pin is clicked

2 participants