module radio renders reset button inoperative

Questions and discussion about running MicroPython on a micro:bit board.
Target audience: MicroPython users with a micro:bit.
Post Reply
rhubarbdog
Posts: 168
Joined: Tue Nov 07, 2017 11:45 pm

module radio renders reset button inoperative

Post by rhubarbdog » Thu Nov 23, 2017 1:46 am

hi, I received my second bbc microbit today so i thought i'd give module radio a try. I can send messages and terminate my programs, but the only way i can get them to restart is pulling the battery out and plugging back in. The RESET button won't work. I've written a producer and consumer

producer:

Code: Select all

from microbit import *

import radio

import user_input as ui

menu=("Hello","","Exit")


radio.on()
while True:

    if button_a.is_pressed():

        while button_a.is_pressed():
            pass

        message=ui.menu_list(menu)

        radio.send(message)

        if message=="Exit":
            break


    display.show("P")
    
radio.off()
i've not included the code for ui.menu_list(), it just takes a tuple or list as parameter and returns one of the elements if the user selects it. It could be replaced with `message=random.choice(menu)`

consumer:

Code: Select all

from microbit import *

import radio

radio.on()
while True:

    message=radio.receive()

    if message=="":
        display.scroll("\'\'")
    elif message:
        display.scroll("\""+message+"\"")
    else:
        display.show("C")

    if message=="Exit" or button_b.is_pressed():
        break

radio.off()
display.clear()
The issue is why are these programs breaking the reset button, it works when plugged into USB but not on battery even with new tested batteries.

rhubarbdog
Posts: 168
Joined: Tue Nov 07, 2017 11:45 pm

Re: module radio renders reset button inoperative

Post by rhubarbdog » Thu Nov 23, 2017 2:48 am

I would have preferred to delete my post this code also blocks the reset button when on battery. It must be that when on battery a programs exit switches the microbit off.

Code: Select all

from microbit import *

while True:
    display.show(Image.HEART)

    if button_a.is_pressed():
        break


display.clear()

Post Reply