Note the PIR sensor needs a separate battery pack as it needs 5v and the micro:bit can only supply 3.3v. Remember it needs to be grounded on both the micro:bit and the second battery pack.. After detecting motion it resets itself after about 5-10 seconds.
from microbit import *
import radio
radio.on()
intruder_state_now = 1
intruder_state_old = 0
while True:
intruder_state_now = pin0.read_digital()
if intruder_state_now != intruder_state_old:
intruder_state_old = intruder_state_now
radio.send(str(intruder_state_now))
display.show(str(intruder_state_now))
from microbit import *
import radio
radio.on()
while True:
x = radio.receive()
if x == '1':
display.show('1')
if x == '0':
display.show('0')
sleep(1000)
The diagram below shows how to wire the sensor to a larger battery pack while still grounding it on the microbit by using a small connector block. You can do this without the connector block by twisting the wires together and securing them with electrical tape.