We just saw how to simplify the program to avoid an obstacle using a My Block (subroutine). Now, we will instead optimize the program using an array, whereas in the LEGO EV3 software, a variable can have one value, an array can have several elements, each with its own value. To learn how an array in EV3 works, you will first need to write a program to display a series of numbers on the EV3 brick screen.
First, clear the display screen. Then define a variable called
Steering. By clicking on the mode selector of the Variable block, we can choose to write to an array instead of writing to a numeric variable. The LEGO EV3 software contains numeric and logic (or Boolean) arrays. It does not currently have arrays for strings (or lists).
We will ...
Sisi tu aliona jinsi ya kurahisisha mpango wa kuepuka kizuizi kutumia My Block (subroutine). Kwa mfano, katika programu ya LEGO, kila kitu kinaweza kuwa na thamani moja, lakini kila kitu kinaweza kuwa na thamani yake. Ili kujifunza jinsi safu ya EV3 inafanya kazi, kwanza unahitaji kuandika programu kuonyesha mfululizo wa namba kwenye skrini ya matofali ya EV3. Kwanza, futa skrini ya kuonyesha. Kisha kufafanua variable aitwaye Steering. Kwa kubonyeza juu ya mode selector ya block variable, tunaweza kuchagua kuandika kwa safu badala ya kuandika kwa variable namba. Programu ya LEGO EV3 ina hesabu na mantiki (au Boolean) safu. Ni kwa sasa haina safu kwa ajili ya safu (au orodha). Tutafanya hivyo...