4. Potentiometer Code Ordering

4.1. Question 1

Put the snippets in order to read the potentiometer position on Pin 2 and immediately output the raeding onto the scrolling LED screen before pausing for a short delay.
Drag and drop lines into the correct order and click to adjust indentation:
☰
sleep(20)
☰
display.scroll(pot_val, delay=80)
☰
from microbit import *
☰
while True:
☰
pot_val = pin2.read_analog()
☰
 

4.2. Question 2

A student hooks up an external LED to Pin 0 alongside their potentiometer on Pin 2.
Order the blocks below to feed the incoming analog potentiometer values straight out to control the LED brightness level.
Drag and drop lines into the correct order and click to adjust indentation:
☰
while True:
☰
pin0.write_analog(pot_val)
☰
from microbit import *
☰
 
☰
sleep(40)
☰
pot_val = pin2.read_analog()

4.3. Question 3

Put the code snippets in order to build a dual-fading light system.
As Pin 0 gets brighter when the potentiometer turns up, Pin 1 must safely dim down by subtracting the potentiometer position from the maximum value.
Drag and drop lines into the correct order and click to adjust indentation:
☰
 
☰
pot_val = pin2.read_analog()
☰
sleep(40)
☰
pin0.write_analog(pot_val)
☰
while True:
☰
pin1.write_analog(1023 - pot_val)
☰
from microbit import *

4.4. Question 4

Put the instructions in the correct order to create a low-threshold safety sensor switch.
If the potentiometer value on Pin 2 drops strictly below 500, a warning indicator light on Pin 0 must switch to fully ON.
Drag and drop lines into the correct order and click to adjust indentation:
☰
else:
☰
pin0.write_digital(1)
☰
from microbit import *
☰
 
☰
if pot_val < 500:
☰
pin0.write_digital(0)
☰
while True:
☰
pot_val = pin2.read_analog()

4.5. Question 5

Order the lines below to build a high-threshold logic split circuit with an embedded status icon tracker.
When the potentiometer crosses 500 or more, turn off Pin 0 and turn on Pin 1 and display a built-in happy face icon to show authorization.
Drag and drop lines into the correct order and click to adjust indentation:
☰
pin1.write_digital(1)
☰
if pot_val >= 500:
☰
pot_val = pin2.read_analog()
☰
display.show(Image.HAPPY)
☰
 
☰
from microbit import *
☰
display.clear()
☰
pin0.write_digital(0)
☰
while True:
☰
pin1.write_digital(0)
☰
pin0.write_digital(1)
☰
sleep(40)
☰
else:

4.6. Question 6

Rearrange the code segments to create a multi-level signal routing system.
Handle low potentiometer signals on Pin 0, middle potentiometer signals on Pin 1, and high potentiometer signals on Pin 8 sequentially.
Drag and drop lines into the correct order and click to adjust indentation:
☰
else:
☰
pin8.write_digital(1)
☰
while True:
☰
 
☰
pin0.write_digital(1)
☰
pot_val = pin2.read_analog()
☰
from microbit import *
☰
if pot_val < 300:
☰
pin1.write_digital(1)
☰
elif pot_val < 600:

4.7. Question 7

Rearrange the code segments to create a multi-level signal routing system.
Use 3 zone switches to handle low potentiometer signals on Pin 0, middle potentiometer signals on Pin 1, and high potentiometer signals on Pin 8 sequentially while ensuring that only one zone is active at a time.
Drag and drop lines into the correct order and click to adjust indentation:
☰
from microbit import *
☰
pin1.write_digital(0)
☰
pin8.write_digital(0)
☰
pin8.write_digital(1)
☰
pin0.write_digital(0)
☰
sleep(20)
☰
pin0.write_digital(0)
☰
else:
☰
pot_val = pin2.read_analog()
☰
pin0.write_digital(1)
☰
# Zone 1 Active Only
☰
if pot_val < 300:
☰
pin8.write_digital(0)
☰
pin1.write_digital(0)
☰
pin1.write_digital(1)
☰
# Zone 2 Active Only
☰
elif pot_val < 600:
☰
 
☰
while True:
☰
# Zone 3 Active Only