# Does anybody know why i have input delay when sending inputs via radio to my other microbit? its for a school project

**URL:** <https://forum.makecode.com/t/does-anybody-know-why-i-have-input-delay-when-sending-inputs-via-radio-to-my-other-microbit-its-for-a-school-project/32580>\
**Category:** micro:bit\
**Created:** [December 18, 2024, 6:20pm UTC](https://forum.makecode.com/t/does-anybody-know-why-i-have-input-delay-when-sending-inputs-via-radio-to-my-other-microbit-its-for-a-school-project/32580 "2024-12-18T18:20:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AUstin](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@AUstin](https://forum.makecode.com/u/AUstin)\
**Post date:** [December 18, 2024, 6:20pm UTC](https://forum.makecode.com/t/does-anybody-know-why-i-have-input-delay-when-sending-inputs-via-radio-to-my-other-microbit-its-for-a-school-project/32580/1 "2024-12-18T18:20:37Z")

</div>

heres the code  
def on\_received\_number(receivedNumber):  
if receivedNumber == 0:  
basic.show\_leds(“”"  
. . . . .  
. . . . .  
. . . . .  
. . . . .  
. . . . .  
“”“)  
elif receivedNumber == 1:  
basic.show\_leds(”“”  
. . # . .  
. # . . .  
# # # # #  
. # . . .  
. . # . .  
“”“)  
elif receivedNumber == 2:  
basic.show\_leds(”“”  
. . # . .  
. . . # .  
# # # # #  
. . . # .  
. . # . .  
“”“)  
elif receivedNumber == 3:  
basic.show\_leds(”“”  
. . # . .  
. # # # .  
# . # . #  
. . # . .  
. . # . .  
“”")  
radio.on\_received\_number(on\_received\_number)

radio.set\_group(1)  
while True:  
if input.button\_is\_pressed(Button.AB):  
radio.send\_number(3)  
elif input.button\_is\_pressed(Button.A):  
radio.send\_number(1)  
elif input.button\_is\_pressed(Button.B):  
radio.send\_number(2)  
else:  
radio.send\_number(0)

im thinking it might be the while true loop?

---

<div class="post-metadata">

**Author:** ![Don](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/don/32/17989_2.png) [@Don](https://forum.makecode.com/u/Don)\
**Post date:** [December 18, 2024, 11:05pm UTC](https://forum.makecode.com/t/does-anybody-know-why-i-have-input-delay-when-sending-inputs-via-radio-to-my-other-microbit-its-for-a-school-project/32580/2 "2024-12-18T23:05:28Z")

</div>

I can’t get that code to go into MakeCode. A share link would be better. I can see what you are trying to do with that while loop and yes that is the problem. You want to return to a blank screen after pushing a button (or two).

Presumably you have this running on two micro:bits with each one able to affect the other. A while loop is never a good idea like that. Use the event handlers instead.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/b/d/bd892239a87a29197790fa9f948b3a3f705e37f7.png)

There are some timing issues involved in using that loop. You can send so many 0 messages that the receiver gets behind and there is a delay as it tries to get through all the 0 before it can see a 1, 2, or 3. It is best to not send that many messages. You may want to explicitly send a clear screen message when the micro:bit is shaken or something.

If that doesn’t work for you consider a forever loop that knows when to clear the screen based on the last time a message was sent. Since this is for school I leave that up to you.
