Pete Prodoehl 🍕 on Nostr: I'm using python.microbit.org to write Python code for the micro:bit but one thing I ...
I'm using python.microbit.org to write Python code for the micro:bit but one thing I don't get is things like:
pin0.write_analog(128)
pin1.write_analog(64)
So like if I want to write a function that will work with any pin how do I do that?
Do I need a big if/else with all the pins? (pin0.write_analog, pin1.write_analog, etc.)
#python #coding #programming #code #microbit
Published at
2024-07-02 16:05:53Event JSON
{
"id": "21a26f2e8102f58745d12c97090781ec8b7fde7098160328380e7d09afd8550f",
"pubkey": "13c0e9d6b2d33b2c82f947f724189bb5929005e06766031f2f0e8868b9bcb711",
"created_at": 1719936353,
"kind": 1,
"tags": [
[
"t",
"python"
],
[
"t",
"coding"
],
[
"t",
"programming"
],
[
"t",
"code"
],
[
"t",
"microbit"
],
[
"proxy",
"https://mastodon.social/users/rasterweb/statuses/112717748843847653",
"activitypub"
]
],
"content": "I'm using python.microbit.org to write Python code for the micro:bit but one thing I don't get is things like:\n\npin0.write_analog(128)\npin1.write_analog(64)\n\nSo like if I want to write a function that will work with any pin how do I do that?\n\nDo I need a big if/else with all the pins? (pin0.write_analog, pin1.write_analog, etc.)\n\n#python #coding #programming #code #microbit",
"sig": "b340b18aaedc09abf14833f0a6d02da7189df419624b7a21b491cad0abb6c4e1009cb3621e6bb2f4a47e1520b1fefb8b9a9082b27e8e7c32e456f3d824160293"
}