AIR GUITAR

PIPER MAKE EDUCATOR RESOURCES SERIES

To do this project, you will need a Piper Make Starter Kit. Get yours here:

Play the Air Guitar with just some code and foil squares!

To get started, head to Piper Make and hit this icon:

Time: 30 minutes

Age Range: 8+

Difficulty: Intermediate

Students will use a circuit similar to the one built in Soil Sensor to create an instrument they can play with their hands.

Note: There are step by step instructions for the students to follow in the tutorials included in each project on Piper Make. These provide directions both for writing code and for building the electronic circuits. The tutorials are well-defined and most students will be able to follow them with little assistance required.

LEARNING OBJECTIVES

Students will:

 

  • Practice breadboarding and wiring
  • Review and understand computational concepts of:
    • loops: running the same sequence multiple times.
    • sequence: identifying a series of steps for a task
  • Demonstrate computational thinking core concepts, including:
    • Algorithm Design by creating an ordered series of instructions for solving similar problems or for doing a task, such as turning a light off and on in the right order.
  • Create programs that include events, loops, and conditionals.
  • Decompose problems into smaller, manageable tasks which may themselves be decomposed.
  • Test and debug a program or algorithm to ensure it accomplishes the intended task.
  • Perform different roles when collaborating with peers during the design, implementation, and review stages of program development.

STANDARDS ALIGNMENT

CSTA's K-12 Standards 

1B-CS-03: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies. Subconcept: Troubleshooting; Practice 6.2

1B-DA-06: Organize and present collected data visually to highlight relationships and support a claim. Subconcept: Collection, Visualization & Transformation; Practice 7.1

1B-DA-07: Use data to highlight or propose cause-and-effect relationships, predict outcomes, or communicate an idea. Subconcept: Inference & Models; Practice 7.1

1B-AP-09: Create programs that use variables to store and modify data. Subconcept: Variables; Practice 5.2

1B-AP-10: Create programs that include sequences, events, loops, and conditionals. Subconcept: Control; Practice 5.2

1B-AP-11: Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process. Subconcept: Modularity; Practice 3.2

1B-AP-12: Modify, remix, or incorporate portions of an existing program into one’s own work, to develop something new or add more advanced features. Subconcept: Modularity; Practice 5.3

CCSS ELA

CCSS.ELA.L.W.3.8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

CCSS.ELA.L.W.3.10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

World-Class Instructional Design and Assessment (WIDA) English Language Proficiency Standards

ELD-SI.K-3.Argue:

  • Ask questions about others’ opinions
  • Support own opinions with reasons
  • Clarify and elaborate ideas based on feedback
  • Defend change in one’s own thinking
  • Revise one’s own opinions based on new information

 

ELD-SC.2-3.Argue.Interpretive:

  • Interpret scientific arguments by
  • Identifying potential evidence from data, models, and/or information from investigations of phenomena or design solutions
  • Analyzing whether evidence is relevant or not
  • Distinguishing between evidence and opinions

California's K-12 Computer Science Standards

3-5.CS.3: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies.

3-5.DA.8: Organize and present collected data visually to highlight relationships and support a claim.

3-5.DA.9: Use data to highlight and/or propose relationships, predict outcomes, or communicate ideas.

3-5.AP.11: Create programs that use variables to store and modify data.

3-5.AP.12: Create programs that include events, loops, and conditionals.

3-5.AP.13: Decompose problems into smaller, manageable tasks which may themselves be decomposed.

3-5.AP.14: Create programs by incorporating smaller portions of existing programs, to develop something new or add more advanced features.

Common Core English Language Arts

CCSS.ELA.L.W.3.8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

CCSS.ELA.L.W.3.10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

California English Language Development Standards

CA ELD.3.C.11: Supporting own opinions and evaluating others’ opinions in speaking and writing

CA ELD.3.C.12: Selecting and applying varied and precise vocabulary and language structures to effectively convey ideas

Michigan Integrated Technology Competencies for Students (MITECS)

1B-CS-03: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies. Subconcept: Troubleshooting; Practice 6.2

1B-DA-06: Organize and present collected data visually to highlight relationships and support a claim. Subconcept: Collection, Visualization & Transformation; Practice 7.1

1B-DA-07: Use data to highlight or propose cause-and-effect relationships, predict outcomes, or communicate an idea. Subconcept: Inference & Models; Practice 7.1

1B-AP-09: Create programs that use variables to store and modify data. Subconcept: Variables; Practice 5.2

1B-AP-10: Create programs that include sequences, events, loops, and conditionals. Subconcept: Control; Practice 5.2

1B-AP-11: Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process. Subconcept: Modularity; Practice 3.2

1B-AP-12: Modify, remix, or incorporate portions of an existing program into one’s own work, to develop something new or add more advanced features. Subconcept: Modularity; Practice 5.3

Michigan English Language Arts

Michigan ELA, Grade 3-8, Research, 8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

Michigan ELA, Grade 3-8, Range of Writing, 10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

WIDA English Language Development

ELD-SI.K-3.Argue:

  • Ask questions about others’ opinions
  • Support own opinions with reasons
  • Clarify and elaborate ideas based on feedback
  • Defend change in one’s own thinking
  • Revise one’s own opinions based on new information

 

ELD-SC.2-3.Argue.Interpretive:

  • Interpret scientific arguments by
  • Identifying potential evidence from data, models, and/or information from investigations of phenomena or design solutions
  • Analyzing whether evidence is relevant or not
  • Distinguishing between evidence and opinions

Science Texas Essential Knowledge & Skills Grade 3

(b)(2) Scientific investigation and reasoning. The student uses scientific practices during laboratory and outdoor investigations. The student is expected to:
(A) plan and implement descriptive investigations, including asking and answering questions, making inferences, and selecting and using equipment or technology needed, to solve a specific problem in the natural world;

(b)(3) Scientific investigation and reasoning. The student knows that information, critical thinking, scientific problem solving, and the contributions of scientists are used in making decisions.

Science Texas Essential Knowledge & Skills Grade 4

(a)(1)(A) Within the physical environment, students know about the physical properties of matter including mass, volume, states of matter, temperature, magnetism, and the ability to sink or float. Students will differentiate among forms of energy including mechanical, light, sound, and thermal energy. Students will explore electrical circuits and design descriptive investigations to explore the effect of force on objects.

(b)(3) Scientific investigation and reasoning. The student uses critical thinking and scientific problem solving to make informed decisions. The student is expected to:

    (A) analyze, evaluate, and critique scientific explanations by using evidence, logical reasoning, and experimental and observational testing;

    (B) represent the natural world using models such as the water cycle and stream tables and identify their limitations, including accuracy and size; and

    (C) connect grade-level appropriate science concepts with the history of science, science careers, and contributions of scientists.

Science Texas Essential Knowledge & Skills Grade 5

(a)(1) In Grade 5, scientific investigations are used to learn about the natural world. Students should understand that certain types of questions can be answered by investigations and that methods, models, and conclusions built from these investigations change as new observations are made. Models of objects and events are tools for understanding the natural world and can show how systems work. They have limitations and based on new discoveries are constantly being modified to more closely reflect the natural world.

(a)(3) Recurring themes are pervasive in sciences, mathematics, and technology. These ideas transcend disciplinary boundaries and include patterns, cycles, systems, models, and change and constancy.

ELA Texas Essential Knowledge & Skills Grade 3

(b) (1)Developing and sustaining foundational language skills: listening, speaking, discussion, and thinking--oral language. The student develops oral language through listening, speaking, and discussion. The student is expected to:

    (A) listen actively, ask relevant questions to clarify information, and make pertinent comments;

    (B) follow, restate, and give oral instructions that involve a series of related sequences of action;

    (C) speak coherently about the topic under discussion, employing eye contact, speaking rate, volume, enunciation, and the conventions of language to communicate ideas effectively;

    (D) work collaboratively with others by following agreed-upon rules, norms, and protocols; and

    (E) develop social communication such as conversing politely in all situations.

ELA Texas Essential Knowledge & Skills Grades 4 & 5

(b) (1)Developing and sustaining foundational language skills: listening, speaking, discussion, and thinking--oral language. The student develops oral language through listening, speaking, and discussion. The student is expected to:

    (A) listen actively, ask relevant questions to clarify information, and make pertinent comments;

    (B) follow, restate, and give oral instructions that involve a series of related sequences of action;

    (C) express an opinion supported by accurate information, employing eye contact, speaking rate, volume, enunciation, and the conventions of language to communicate ideas effectively; and

    (D) work collaboratively with others to develop a plan of shared responsibilities.

(b)(13) Inquiry and research: listening, speaking, reading, writing, and thinking using multiple texts. The student engages in both short-term and sustained recursive inquiry processes for a variety of purposes. The student is expected to:

    (A) generate and clarify questions on a topic for formal and informal inquiry;

    (B) develop and follow a research plan with adult assistance;

    (C) identify and gather relevant information from a variety of sources;

    (D) understand credibility of primary and secondary sources;

    (E) demonstrate understanding of information gathered;

    (F) differentiate between paraphrasing and plagiarism when using source materials;

    (G) develop a bibliography; and

    (H) use an appropriate mode of delivery, whether written, oral, or multimodal, to present results.

§74.4. English Language Proficiency Standards

(c) Cross-curricular second language acquisition essential knowledge and skills.

(3) Cross-curricular second language acquisition/speaking.

(D) speak using grade-level content area vocabulary in context to internalize new English words and build academic language proficiency;

(E) share information in cooperative learning interactions;

(F) ask and give information ranging from using a very limited bank of high-frequency, high-need, concrete vocabulary, including key words and expressions needed for basic communication in academic and social contexts, to using abstract and content-based vocabulary during extended speaking assignments;

(G) express opinions, ideas, and feelings ranging from communicating single words and short phrases to participating in extended discussions on a variety of social and grade-appropriate academic topics;

(H) narrate, describe, and explain with increasing specificity and detail as more English is acquired;

CONCEPTS

Students will use loops, actions, and variables to collect and display data.

PARTS

  • Pico and Breadboard
  • (10) M2M Jumper Wires
  • (2) Alligator Clip Wires
  • (1) Bar Graph LED
  • (10) 330 Ohm Resistors
  • (2) 1 Mohm Resistors

GPIO SETUP

OVERVIEW OF STEPS

Step 1: Air Guitar

In this activity, we're going to build an air guitar!

In this lesson we will build a circuit that will sense the presence of your hand. We will use this circuit to make music.

Sound fun? Let's get started.

If you've already built the Soil Sensor tutorial, the circuit in this activity will be similar.

Step 2: Grab Your Stuff

You will need:

  • Pico and Breadboard
  • (10) M2M Jumper Wires
  • (2) Alligator Clip Wires
  • (1) Bar Graph LED
  • (10) 330 Ohm Resistors
  • (2) 1 Mohm Resistors

 

You will also need:

  • (2) 2"x2" Foil Squares

Step 3: Build Your Circuit Board

Grab your Pico and breadboard, as well as the bar graph LED. Attach the bar graph LED along the center of the breadboard opposite the Pico. The center gap on your board should pass under the middle of your bar graph LED lengthwise.

The letters and numbers on the side of the bar graph LED should be on the side shown by the arrow below.

Next, we're going to connect the 330 Ohm resistors to the bar graph LED. Connect 1 resistor in line with each LED bar - you should have 10 total. Then connect the other end of each resistor to the ground bar along the blue line on the outer edge of the breadboard.

First, connect a M2M jumper wire from a GROUND pin on the top of your Pico to the Ground row on the top of your Breadboard.

Now, we're going to connect the M2M jumper wires. Connect 1 wire in line with each LED bar, opposite the 330 Ohm resistors. It doesn't matter which color wires you use. Next, connect the other end of each wire to the GPIO pins of your Pico, beginning with GP15, then GP14, GP13, and so on until you've reached GP6. If you are having a hard time telling which pins of the pico you should connect to, use the DIGITAL VIEW tab at the bottom of the screen for a helpful diagram!

Step 4: Build a test program

Let's add some blocks that will help us read the output from our foil squares.

Grab a start block from the Chip menu and place it in the workspace. Then, grab a repeat forever block and connect it to the start block.

Next, grab a graph number data block from the Actions menu and place it inside of the repeat forever block.

Click the blue gear icon on the graph number data block. In the mini workspace that opens up, drag a value block into the send block so that there are two value blocks:

Click the blue gear icon again to close the mini workspace.

Grab a capacitive sense block from the Sensing menu and place it into the first input of the graph number block. Make sure the pin is set to pin 0. Grab another capacitive sense block and place it into the second input of the graph number block. Set the pin is set to pin 4:

Step 5: Graph the sensors

Our test program is ready, so let's run it!

First, flip your foil squares over so that the paper side is facing up.
Click the DATA tab at the bottom of the workspace to open the graph. Next, click CONNECT. Select your Pico, then click START.

Go ahead and try touching the sensors - watch what happens to the graph when you do:

When you touch the back of the foil square connected to GP0, the blue line jumps higher. When you touch the back of the foil square connected to GP4, the teal line jumps higher.

Experiment and see if it changes when you touch the sensor lightly with one finger versus pressing against the sensor with 3 or 4 fingers.


Go ahead and click STOP.

Look carefully at your graph. Your values might be slightly different, but if you are not touching the sensor, the value of the graph is probably less than 2000, and it jumps as high as 6000 when you are touching the sensor with 3 or 4 fingers.

Step 6: How does the sensor work?

How does the soil moisture sensor work anyway? It uses a property of materials called capacitance. Capacitance is an object's ability to hold an electric charge.

When we connect the Pico to a piece of metal like one of the copper strips in side of the sensor, the Pico can charge the copper strip by raising it's voltage up to 3.3V. The Pico does this really fast, and it makes the copper strip positively charged:

If something like your hand, finger, or water is really close to the copper strip, it can hold more of a positive charge:

Next, the Pico tells the pin that sent the charge to stop sending and instead to become an input so that it can read the voltage of the copper strip:

The reason we use a really big resistor is to prevent the charge from draining back to the ground pin too quickly. While the foil's positive charge is draining away, the Pico is taking measurements of the voltage. When the voltage drops down close to zero, it stops and takes note of how long it took to drain the charge:

If the positive charge drained away quickly, there wasn't something touching or very close to the sensor. If it drained away more slowly, something like your hand or water was close enough to the foil. That's how it can tell!

What's even crazier is that the whole measurement - from charging the foil to letting it drain away - only takes 0.005 seconds. That means the Pico can take 20 measurements in the same amount of time that it takes you to blink your eyelids once!
Click NEXT.

Step 7: Waiting until...

Our instrument needs to have two inputs - one input to let the Pico know when to play a note, and another input to know what note to play. Let's start with the input that tells the Pico when to play a note.

Remember when you graphed the reading from your sensor and it showed that when you are touching the sensor, it's value goes over 2000?

Normally, you would use an if block to do this, but we are doing to try something a little different. Since we want our program to wait for us to press the button, and we will eventually want our program to do something while it's waiting, we are going to use a repeat while block.
Grab a repeat while block from the Loops menu and connect it below the graph number block. Grab a _ = _ from the Logic menu and place it into the input of the repeat while block. Then, grab the first capacitive sense block from inside of the graph number block and place it into the left side of the _ = _ block. Next, change the = (equals) to a < (less than). Grab a 0 block from the Values menu and place it into the right side of the _ = _ block. Change the 0 to 2000:

Next, let's add a sound to play.

Grab the play sound block from the Sounds menu and connect it below the repeat while block. Then, grab an instrument block from the Sounds menu and place it into the input of the play sound block. Finally, change the wait time on the repeat forever block to 0.1 seconds:

Step 8: Capture that value!

We are almost ready to test out what we have built so far.

Let's store the value from the foil square connected to GP4 into a variable. Click the Variables menu to open it. Then, click the Create variable button and name your new variable "foil square".

Grab the set foil square block and place it into the repeat while block. Then, drag the capacitive sense pin 4 block from the graph number block into the input of the set foil square block. Then, right-click the graph number block and choose Delete Block:

You're ready to try your instrument! Right now, it will only play one note, but it will play that note any time you tap the foil connected to GP0.

Click START, and try tapping the foil square. When you're done, click STOP.

Cool, right? No we just need to make the second foil determine what note to play.

Grab the note block from inside of the instrument block and place it off to the side. Then, grab a map value block from the Logic menu and place it into the pitch input of the instrument block:

Grab a foil square block from the Variables menu and place it into the map value block's input.

Now, we need to try to remember the values we got when we were touching the foil square and when we weren't. They were probably something like 1500 to 4000. Your values might have been a little different, and you can experiment by adjusting these numbers later.

Let's type these numbers into the from range of the map value block. Replace 0 with 1500, and replace 50 with 4000:

Step 9: Play that note!

We are almost ready to try out our instrument!

Now that we have set the from range, we need to set the to range. We are going to use notes for our to range values, so the first thing you need to do is grab the 0 and 100 blocks and drag them to the trashcan to delete them. Then, grab the note block you set off to the side earlier and place it into one of the to range inputs.

Right-click the note block and select Duplicate. Place the new block into the other to range input. Click the left note block to set the note to a low value. Then, click the other note block to set its value to a higher note:

You're instrument is ready! Go ahead and click START to try it!

Once you've played it a bit, go ahead and click STOP.

That was cool, but honestly, it was probably a bit hard to play - and the notes bounced all over the place, didn't they? Let's see if we can make it better.

Click NEXT.

Step 10: Add some feedback

One thing that will help you play your instrument is something called feedback. Feedback is where the instrument tells you something about what it is sensing.

We are going to use the bar graph LED to help us know how hard or soft to press the foil square so we know what note we are playing.

Grab a setup bar graph led block and connect it between the start block and the repeat forever block. Set the start pin to 15 and the end pin to 6. Then, grab a bar graph display block and connect it right below the set foil square block. Drag the 1 block inside of the bar graph display block to the trashcan to delete it:

Grab another map value block from the Logic menu and place it into the input of the bar graph display block. Then, grab a foil square block from the Variables menu and place it into the input of the map value block. Change the from range values to 1500 and 4000, and change the to range values to 0 and 10:

Before you try out your program, there is one thing that we need to do. Click on the DIGITAL VIEW tab at the bottom of the workspace. Click the switch on the left side of the Digital View to turn it off. Then, click the DIGITAL VIEW tab again to close it.

Let's try your program again. Go ahead and click START to try it out.

Once you've played it a bit, go ahead and click STOP.

Did the feedback help? Were you able to control the note being played a bit more easily with some feedback from the instrument?

Click NEXT.

Step 11: Smooth like Jazz

Having some feedback probably helped you play your instrument, but it probably still didn't sound very good. Do you remember the graph from the beginning of the tutorial?

The values kind of bounce all over the place when you touch the foil square, right? That's what is making the notes bounce all over the place, too.

We need to find a way to "smooth" those values out. We will do this using a cool math trick - we will add the previous sensor readings in with the new sensor reading, and then average them back out.

Right-click the set foil square block and choose Duplicate. Place the new block between the start block and the set up bar graph block.

Next, go back to the set foil square block inside of the repeat while block. Grab the capacitive sense block and drag it out and off to the side:

Next, grab a _ + _ block from the Logic menu and place it into the input of the set foil square block. Then, grab a foil square block from the Variables menu and place it into the left side of the _ + _ block. Change the + (plus) to a × (times). Grab a 0 block from the Values menu and place it into the right side of the _ × _ block. Change the 0 to a 3:

Right-click the set foil square block inside of the repeat while block and select Duplicate. Connect the new block right below the set foil square block you just copied. In the new blocks, change the × (times) to a + (plus). Next, remove the 3 block and drag it to the trashcan to delete it. Then, drag the capacitive sense block you set off to the side earlier into the input you just opened up:

Step 12: Finish it up

We are almost there!

We just added blocks that make the value in the foil square variable larger. The first ones we added multiply the foil square variable by 3. The next blocks add another sensor reading. This means that the foil square variable is approximately four times larger.

That means that the next thing we should do is divide the variable by 4.

Find the first set foil square block inside of the repeat while block. Right-click it and select Duplicate. Connect the new blocks between the last set foil square block and the bar graph display block. In the new blocks, change the × (times) to a ÷ (divide by), and change the 3 to 4.:

That's it! Let's try it again. Go ahead and click the START button to run your program.

Once you've played your instrument a bit, go ahead and click STOP.

Better, right? With feedback and smoothing, your instrument is much easier to play. Now, with a little practice, you can play some awesome music!

Try changing the instrument and the duration values in the instrument block to come up with even more interesting and cool sounds.

Can you think of other ways to convert the input values from your foil squares into musical notes? Play around with your program and see what you can come up with!

Click NEXT.

Step 13: You Finished!

Click EXIT to return to the menu and start your next coding challenge.