[Microbit-Python] Sending an integer by radio

David Booth david.f.booth at googlemail.com
Mon Dec 19 15:44:27 EST 2016


Hi Thierry
Thank you very much for you reply.  In my case I need to send a range of
integers from -1023 to +1023 and it has been pointed out to me that I have
to do more than convert them to a string and on reception convert them to
an integer because if I do just that I get a Type error of None. This is
the receiving script snippet which has been suggested and works should you
ever have the need.


    radio.on()
    accel_str = None
    while not accel_str:
        accel_str = radio.receive()
    accel = int(accel_str)

Thanks again
Have a happy Christmas.
David


On 19 December 2016 at 14:23, Thierry Chantier <titimoby at gmail.com> wrote:

> If you want, I published some code I used with kids to play with radio
> messages.
> https://github.com/titimoby/microbit4all/tree/master/src/radio
>
>
> Le lun. 19 déc. 2016 à 15:21, danny staple <danny at orionrobots.co.uk> a
> écrit :
>
>> I am slightly ignorant on all this (not tried playing with 2 microbits)
>> but is there a packet size limit - or does it automatically send stuff? Is
>> the json module available?
>>
>> On Mon, 19 Dec 2016 at 11:25 Mark Shannon <mark at hotpy.org> wrote:
>>
>> Hi David,
>>
>> Just convert the integer value to a string and then send that.
>> send:
>> radio.send(str(x_accel))
>> receive:
>> x_accel = int(radio.recv())
>>
>> Mark.
>>
>> On 18/12/16 16:36, David Booth via Microbit wrote:
>> > Hi
>> > I have two micro:bits.  How do I send the x acceleration (i.e.+/- 0 to
>> > 1023) from one to a variable x_accel on the other by radio?
>> >
>> > Thank you
>> > David
>> >
>> >
>> > _______________________________________________
>> > Microbit mailing list
>> > Microbit at python.org
>> > https://mail.python.org/mailman/listinfo/microbit
>> >
>> _______________________________________________
>> Microbit mailing list
>> Microbit at python.org
>> https://mail.python.org/mailman/listinfo/microbit
>>
>> --
>> <a href='http://www.justgiving.com/Daniel-Staple' title='JustGiving -
>> Sponsor me now!' target='_blank'><img src='http://www.justgiving.
>> com/App_Themes/JustGiving/images/badges/badge9.gif' width='120'
>> height='90' alt='JustGiving - Sponsor me now!' /></a>
>> _______________________________________________
>> Microbit mailing list
>> Microbit at python.org
>> https://mail.python.org/mailman/listinfo/microbit
>>
>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/microbit/attachments/20161219/3e9a284c/attachment.html>


More information about the Microbit mailing list