Hello,
I got my son a pybadge so he can learn to code using blocks in makecode arcade. We're wondering if there's a way to read the analog pin that carries the battery charge level using blocks via an extension perhaps?
Thanks in advance
Pybadge / Makecode. Can you access pin values to make a battery indicator?
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- krztoff
- Posts: 10
- Joined: Tue Apr 20, 2010 6:45 pm
- mikeysklar
- Posts: 12454
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Pybadge / Makecode. Can you access pin values to make a battery indicator?
From the PyBadge pinout page things looks good. A6 in the magic battery pin.
You should be able to use the read analog pin block.Pin A6 is connected to a voltage divider which gives half the current battery voltage. You can read the battery voltage by using the Arcada library function readBatterySensor() (it multiplies by two to give the actual voltage), by using analogRead(A6) in Arduino, or by using analogio.AnalogIn(board.A6) in CircuitPython.
- krztoff
- Posts: 10
- Joined: Tue Apr 20, 2010 6:45 pm
Re: Pybadge / Makecode. Can you access pin values to make a battery indicator?
I don't have that block. Is there an extension specifically for the pybadge that adds that? I see the edgeconnector extension which allows something similar, but A6 isn't an option (only Px where x= 0 - 31)
- mikeysklar
- Posts: 12454
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Pybadge / Makecode. Can you access pin values to make a battery indicator?
Read analog should be available to all MakeCode builds with analog pins.
Is this the block in question or a different one?
Another code block example which might be helpful to finding those analog pins.
Is this the block in question or a different one?
Another code block example which might be helpful to finding those analog pins.
- krztoff
- Posts: 10
- Joined: Tue Apr 20, 2010 6:45 pm
Re: Pybadge / Makecode. Can you access pin values to make a battery indicator?
I think part of my confusion is that there exists both:
makecode.adafruit.com
and
arcade.makecode.com
The instructions I've seen refer to the latter as being the correct site on which to program for the PyBadge. This is further reinforced by the fact that the PyBadge is specifically listed as an option when you choose to download your project and it asks you to specify your hardware. However arcade.makecode.com doesn't have an extension that opens up access to the PyBadge's pins as far as I can tell. I can only find an equivalent to what you posted on the makecode.adafruit.com page, but on that page we don't have any way to program for the PyBadge as it only appears to support the "Adafruit Circuit Playground Express".
I'm sure i'm doing something wrong here, but I promise I've tried and tried to answer this myself.
Here's what's available on arcade.makecode.com by default:
makecode.adafruit.com
and
arcade.makecode.com
The instructions I've seen refer to the latter as being the correct site on which to program for the PyBadge. This is further reinforced by the fact that the PyBadge is specifically listed as an option when you choose to download your project and it asks you to specify your hardware. However arcade.makecode.com doesn't have an extension that opens up access to the PyBadge's pins as far as I can tell. I can only find an equivalent to what you posted on the makecode.adafruit.com page, but on that page we don't have any way to program for the PyBadge as it only appears to support the "Adafruit Circuit Playground Express".
I'm sure i'm doing something wrong here, but I promise I've tried and tried to answer this myself.
Here's what's available on arcade.makecode.com by default:
- krztoff
- Posts: 10
- Joined: Tue Apr 20, 2010 6:45 pm
Re: Pybadge / Makecode. Can you access pin values to make a battery indicator?
I guess to summarize, my question is: How do I get these blocks into arcade.makecode.com so they can be used to develop for my son's specific device and it's capabilities?mikeysklar wrote: ↑Thu Sep 07, 2023 2:17 pm Read analog should be available to all MakeCode builds with analog pins.
Is this the block in question or a different one?
Screenshot 2023-09-07 at 11.16.37 AM.png
Another code block example which might be helpful to finding those analog pins.
Screenshot 2023-09-07 at 11.58.12 AM.png
- krztoff
- Posts: 10
- Joined: Tue Apr 20, 2010 6:45 pm
Re: Pybadge / Makecode. Can you access pin values to make a battery indicator?
does anyone have any ideas?
- krztoff
- Posts: 10
- Joined: Tue Apr 20, 2010 6:45 pm
- dirtyrob
- Posts: 38
- Joined: Mon Jun 25, 2012 8:46 pm
Re: Pybadge / Makecode. Can you access pin values to make a battery indicator?
Hello Krztoff,
I believe you just need to use the Feather extension. There's an example in the Plantagotchi project by John Park:
https://learn.adafruit.com/plantagotchi ... ode-arcade (Under the Extensions section).
-Rob
I believe you just need to use the Feather extension. There's an example in the Plantagotchi project by John Park:
https://learn.adafruit.com/plantagotchi ... ode-arcade (Under the Extensions section).
-Rob
Please be positive and constructive with your questions and comments.