Page 1 of 1

3.3V mini solar tracking system coding problem

Posted: Tue Nov 26, 2024 5:03 pm
by RobSieloff
Hi Folks first time here and this will be an easy question. but my Gr 8 daughter nor I can rewrite one line of code.
We are trying to change the code in the tutorial video
from :
analog read pin P1

TO:
set voltage to 3.3 × analog read pin P1 / 1023

We are unfamiliar with how to manipulate the code blocks such that we get:

set voltage to 3.3 × analog read pin (0 / 1023)

the division formula in brackets or in purple in coding area does not give us what we need. The P1 is underneath of the purple division formula. If that is understandible to anyone(?)

We have servo working but struggle to get the mini solar panel voltage to be read on either the microbit led's or on the laptop. I have voltage tested output solar with a volt meter at the micro:bit , ranging from 1 to 3.4v using room lighting and/or flashlight.
Thx in advance Rob for Sofia my gr8'R

(Administrator note / project url: https://www.sciencebuddies.org/science- ... ar-tracker )

Re: 3.3V mini solar tracking system coding problem

Posted: Wed Nov 27, 2024 10:33 am
by amyCC
Hi - You are having trouble getting the blocks in place to create this, correct?
setformula1.png
setformula1.png (27.02 KiB) Viewed 11852 times
To do this, first add the "set voltage" variable (which it sounds like you have).

Add a math equation for the multiplication to the right side:
forumua1b.png
forumua1b.png (50.9 KiB) Viewed 11852 times

Then add another math equation for the division into the right side of the previous equation:
formula1c.png
formula1c.png (80.83 KiB) Viewed 11852 times

Drop the analog pin block (from the pins menu) into the left side of the division equation:
setformula1d.png
setformula1d.png (126.81 KiB) Viewed 11852 times
If you are having trouble with that specific block, you might try putting the block on your screen separately. Then drag it onto the equation, watching for the left-side 0 to highlight in yellow so that you can drop it into that. Then update the other block in the equation (to change it to 1023).

We would love to hear how the project goes for your student!

Let us know if you have questions.

Amy
Science Buddies