Edson Sobreira
Edson Sobreira

Reputation: 1

Python - micro:bit add a variable in a function

I am trying to add a variable 'ch' for a radio function in microbit, but always I compile I receive an error message.

The idea is send any argument to ch to be incorporate in the radio config function.

from microbit import *
import radio
radio.on()
#-----------
# This channel can vary due to an external input
ch = 30
radio.config(channel=ch) # the original syntaxes is: radio.config(channel=7)

#-------------------

Appreciate if someone can help.

Upvotes: 0

Views: 227

Answers (1)

phil
phil

Reputation: 565

Your error isn't coming from the radio.config(channel=ch) line it's display.scroll("channel" % ch) should read display.scroll("channel %d" % ch)

Upvotes: 1

Related Questions