← Back to Book Detail

Blue Unit: Computational Tinkering (17/19) -- A Person-Centered Guide to Demystifying ...

Browse
89%

Blue Unit: Computational Tinkering

Blue Unit: Computational Tinkering 3B: Build Functions for Remixable Code Background Knowledge Probe Reusing/remixing code is a central tenet of the free and open source software movement. And indeed, it’s a central tenet of the Internet, as we’ll discover in the Rainbow Unit. But as we’ve discovered throughout the book and especially highlighted in The Unknown Tech Innovators, there’s also an active work to give the credit for innovations to certain people, and particularly to white males. Take a few minutes now to reflect back on the innovative designers and builders of the code we’re now using for our own Community of Practice works, and especially those hidden and forgotten that we’ve worked to bring forward as part of our explorations. - - How has their work helped shape your own use and reuse/remixing works? - In what ways might your remixes be used by others in their works? Technical Review Exercise: Variables & Functions Remix of the Toolbox Trumpet Let’s begin by considering how we could remix the Toolbox Trumpet using variables and functions to expand the capabilities of this tool. Steps: Creating a binary to decimal calculator To begin, we will create a new variable and use conditionals to collect the values, 000 to 111, provided using the three “valves.” We will use this to calculate the decimal notation equivalent, 0, 1, 2, 3, 4, 5, 6, or 7.[1] - In the VARIABLES category, create a new variable called CapTouchCounter . This will be used to determine which capacitive touch sensor “valve” or “valves” are pressed in that sequence. - Drag a “set CapTouchCounter to 0” block from the VARIABLES category and place it in the default FOREVER function. - Add three “If…Then” blocks from the LOGIC category to the FOREVER function, and configure them using a “button A is pressed” block from the INPUT category to have conditionals for pin A1, pin A2, and pin A3. - In each of the “If…Then” conditionals, add a “change CapTouchCounter by” block. Set the pin A1 conditional so that CapTouchCounter is changed by 1. Set the pin A2 conditional so that CapTouchCounter is changed by 2. Set the pin A3 conditional so that CapTouchCounter is changed by 4. - Under advanced, go down to the CONSOLE category. From there, drag a “console log” block and add it as the last line of code in the new FOREVER function. - Finally, from the VARIABLES category, drag a “CapTouchCounter” block and drop it into the right oval window of the “console log” block. Here’s a video screenshot of these steps to compare with your own process. Feel encouraged to change 1X to 2X to play it back at high speed. Note that the console provides a means to enter a new level of testing within the simulator. Remember that we cannot test the pressing of multiple capacitive touch sensors simultaneously. At this point, we can only assume the “change” statement will add in the value, rather than replacing the previous value. Steps: Playing the Middle C Scale As we move forward, much of the time we use
← Previous Chapter Next Chapter →