How the Wireless Controlled Bot Project Works
Like the transmitter project, the wireless receiver project’s radio call is also similar to countdown_receiver.
Inside the on radio received (rLongString) loop, the project waits for the radio to receive a signal. If the micro:bit has not received a radio message, it returns None. If the micro:bit receives a packet (because you finished typing all three values and pressed Enter), then on radio received returns a string that contains the dictionary. That gets stored in a variable named rLongString.
When on radio received returns None, the rest of the project gets skipped and the loop gets ignored. When on radio received returns a string (with characters that represent a dictionary), the statements under if (not ((rLongString) is empty)) are executed, starting with printing the packet. (You can only see that if you have the cyber:bot tethered and connected to a terminal.)
This statement converts a string containing a dictionary into an actual dictionary. The result is named dictionary.
Assuming you typed 25, -25, 1000 in response to the prompts, the dictionary will be something like {‘vL’: 25, ‘vR’: -25, ‘ms’: 1000}. (Again, the order of the key-value pairs doesn’t matter since you use the key to find its corresponding value.) These statements use the ‘vL’, ‘vR’, and ‘ms’ keys to fetch the 25, -25, and 1000 values.
With the variables named vL, vR, and ms now storing the correct values, all that’s left is to make the left and right wheels turn at 25 and -25. And, keep that maneuver going for 1000 ms with pause before stopping the servos again.