Minor fixes to guitar demo

This commit is contained in:
Richard Knoll 2016-10-03 16:37:13 -07:00
parent 5e9eec61c5
commit aea09c1830
5 changed files with 145 additions and 145 deletions

View File

@ -1,10 +1,10 @@
# Guitar # Guitar
![guitar icon](/static/mb/projects/guitar.png) ![guitar icon](/static/mb/projects/guitar.png)
### @description A beginner-intermediate maker activity, building a guitar with the micro:bit ### @description A beginner-intermediate maker activity, building a guitar with the micro:bit
### ~avatar avatar ### ~avatar avatar
Make a micro:bit guitar with this guided tutorial! Make a micro:bit guitar with this guided tutorial!
### ~ ### ~
*playing micro:bit guitar* *playing micro:bit guitar*
@ -12,24 +12,24 @@ https://youtu.be/GYmdTFvxz80
## Duration ## Duration
5 Activities, approx 30-45 min each based on familiarity with the coding concepts 5 Activities, approx 30-45 min each based on familiarity with the coding concepts
## Materials ## Materials
* Cardboard large pieces (recycle!) * Cardboard large pieces (recycle!)
* Tape (masking, duct Tape, and/or packing tape) * Tape (masking, duct tape, and/or packing tape)
* Markers and/or paint * Markers and/or paint
* Aluminum Foil * Aluminum Foil
* Scissors that can cut cardboard * Scissors that can cut cardboard
* 1 micro:bit, battery holder and 2 AAA batteries * 1 micro:bit, battery holder and 2 AAA batteries
* 4-5 Crocodile clips * 4-5 Crocodile clips
* Headphones * Headphones
## Activities ## Activities
* [Making the Guitar Body](/projects/guitar/making) * [Making the Guitar Body](/projects/guitar/making)
* [Buttons, Display & Sound](/projects/guitar/displaybuttons) * [Buttons, Display & Sound](/projects/guitar/displaybuttons)
* [Light Sensor Tone control](/projects/guitar/lightsensor) * [Light Sensor Tone control](/projects/guitar/lightsensor)
* [Accelerometer Beat control](/projects/guitar/accelerometer) * [Accelerometer Beat control](/projects/guitar/accelerometer)
* [Pin Press Switch](/projects/guitar/pinpress) * [Pin Press Switch](/projects/guitar/pinpress)
### ~button /projects/guitar/making ### ~button /projects/guitar/making
Let's get started! Let's get started!

View File

@ -2,7 +2,7 @@
### @description micro:bit guitar: using buttons with display and sound ### @description micro:bit guitar: using buttons with display and sound
### ~avatar avatar ### ~avatar avatar
Use Button Events to control LED Display and play Sound Use Button Events to control LED Display and play Sound
* **Concepts:** * **Concepts:**
* Events * Events
* Tone/Note * Tone/Note
@ -42,8 +42,8 @@ music.rest(music.beat(BeatFraction.Whole))
music.beat(BeatFraction.Quarter) music.beat(BeatFraction.Quarter)
``` ```
## Step 1: Make a Smiley ## Step 1: Make a Smiley
Open [codethemicrobit.com](https://codethemicrobit.com) in your web browser Open [codethemicrobit.com](https://codethemicrobit.com) in your web browser
```blocks ```blocks
basic.showLeds(` basic.showLeds(`
. # . # . . # . # .
@ -53,14 +53,14 @@ Open [codethemicrobit.com](https://codethemicrobit.com) in your web browser
. # # # . . # # # .
`); `);
``` ```
From **Basics**, drag a **show LEDs** block into the coding area From **Basics**, drag a **show LEDs** block into the coding area
* Create a face with LEDs * Create a face with LEDs
![micro:bit USB connection](/static/mb/projects/guitar/connectmicrobit.jpg) ![micro:bit USB connection](/static/mb/projects/guitar/connectmicrobit.jpg)
Connect your micro:bit to your computer via USB and click **`Download`**. Connect your micro:bit to your computer via USB and click **`Download`**.
Follow the instructions to move the code to your micro:bit. Follow the instructions to move the code to your micro:bit.
## Step 2: Add Smiley LED Button Events ## Step 2: Add Smiley LED Button Events
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.onButtonPressed(Button.A, () => {
basic.showLeds(` basic.showLeds(`
@ -82,36 +82,36 @@ input.onButtonPressed(Button.B, () => {
}) })
``` ```
From **Input**, drag an **on button 'A' pressed** block into the coding area From **Input**, drag an **on button 'A' pressed** block into the coding area
* Snap the LED face into the block * Snap the LED face into the block
* Create a 'B' button block with a different LED face * Create a 'B' button block with a different LED face
* Download the code to your micro:bit and try the A & B buttons * Download the code to your micro:bit and try the A & B buttons
## Step 3: Add Headphone Speakers using Crocodile clips ## Step 3: Add Headphone Speakers using Crocodile clips
![crocodile clips attached to pins 0 and GND](/static/mb/projects/guitar/crocclipintoboard.jpg) ![crocodile clips attached to pins 0 and GND](/static/mb/projects/guitar/crocclipintoboard.jpg)
![crocodile clips attached to headphone jack](/static/mb/projects/guitar/jacktocrocs.jpg) ![crocodile clips attached to headphone jack](/static/mb/projects/guitar/jacktocrocs.jpg)
Connect **GND** to the **base of the headphone jack** using a second crocodile clip (usually black) Connect **GND** to the **base of the headphone jack** using a second crocodile clip (usually black)
Connect **pin 0** to the **tip of the headphone jack** with a crocodile clip Connect **pin 0** to the **tip of the headphone jack** with a crocodile clip
*attaching batteries and micro:bit* *attaching batteries and micro:bit*
https://youtu.be/zwRTmpKIaVU https://youtu.be/zwRTmpKIaVU
Attach the micro:bit & battery-pack to the guitar body Attach the micro:bit & battery-pack to the guitar body
*connecting headphone speaker*
https://youtu.be/ewyEW_U5G9M
Connect the headphones with crocodile clips
*connecting headphone speaker*
https://youtu.be/ewyEW_U5G9M
Connect the headphones with crocodile clips
### ~hint ### ~hint
## The micro:bit can play music ## The micro:bit can play music
The **play tone** block allows a range letter note tones from **C** to **B5**. The **play tone** block allows a range letter note tones from **C** to **B5**.
Songs are played using sequences notes. Like the beginning of a birthday song (C, C, D, C, F, E). Songs are played using sequences notes. Like the beginning of a birthday song (C, C, D, C, F, E).
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.onButtonPressed(Button.A, () => {
@ -152,20 +152,20 @@ input.onButtonPressed(Button.B, () => {
`) `)
music.playTone(Note.G, music.beat(BeatFraction.Whole)) music.playTone(Note.G, music.beat(BeatFraction.Whole))
}) })
``` ```
From **Music**, drag **play tone *C* for *1* beat** block under the **show leds** in **Button A Pressed** From **Music**, drag **play tone *C* for *1* beat** block under the **show leds** in **Button A Pressed**
* modify **tone** by choosing a note (*letter*) and experiment with high and low pitches * modify **tone** by choosing a note (*letter*) and experiment with high and low pitches
* set **beat** to 1 * set **beat** to 1
**Repeat** for **Button B** event **Repeat** for **Button B** event
**Download the code** to the micro:bit **Download the code** to the micro:bit
**Try the A & B buttons** with headphones and power connected **Try the A & B buttons** with headphones and power connected
## Congratulations on completing the basic guitar! ## Congratulations on completing the basic guitar!
**Challenge:** Create Samples of longer music to play for each button instead of the single tone **Challenge:** Create samples of longer music to play for each button instead of the single tone
* *Tip*: Search for "ABC music notation" or "Easy Music Notes" + the name of a song * *Tip*: Search for "ABC music notation" or "Easy Music Notes" + the name of a song
## Extra ## Extra

View File

@ -4,7 +4,7 @@
### ~avatar avatar ### ~avatar avatar
Use the Light Sensor to the control tone for this [Theremin](https://en.wikipedia.org/wiki/Theremin) inspired guitar Use the Light Sensor to the control tone for this [Theremin](https://en.wikipedia.org/wiki/Theremin) inspired guitar
* **Concepts:** * **Concepts:**
* Inputs * Inputs
@ -12,19 +12,19 @@ Use the Light Sensor to the control tone for this [Theremin](https://en.wikiped
* Tone/Frequency * Tone/Frequency
* Ratio Mapping * Ratio Mapping
* Forever Loop * Forever Loop
* Math (multiplication) with code properties * Math (multiplication) with code properties
### ~ ### ~
## Duration: 30 - 45 minutes ## Duration: 30 - 45 minutes
*playing tones with light sensor* *playing tones with light sensor*
https://youtu.be/2cKg9pokVC4 https://youtu.be/2cKg9pokVC4
## The micro:bit LEDs Light Sensors ## The micro:bit LEDs Light Sensors
- the micro:bit can detect external light level intensity reaching the LEDs - the micro:bit can detect external light level intensity reaching the LEDs
- the light level block reports a reading of values 0 (*dark*) to 255 (*bright*) - the light level block reports a reading of values 0 (*dark*) to 255 (*bright*)
- a **Forever Loop** is required to continually use measure the current light level to control the tone - a **Forever Loop** is required to continually measure the current light level and control the tone
## Forever Loop ## Forever Loop
@ -46,70 +46,70 @@ basic.forever(() => {
}) })
``` ```
**Build the blocks** **Build the blocks**
* From **Basic** drag a **forever loop** block into the coding area * From **Basic** drag a **forever loop** block into the coding area
* From **Led** drag a **plot bar graph** block into the **forever loop** * From **Led** drag a **plot bar graph** block into the **forever loop**
* From **Input** drag a **light level** block into **plot bar graph *of*** * From **Input** drag a **light level** block into **plot bar graph *of***
**Set the *plot bar graph* value *up to* = *255* **
## Step 2: Test the light required to move the bar graph height **Set the *plot bar graph* value *up to* = *255* **
*graphing light input* ## Step 2: Test the light required to move the bar graph height
https://youtu.be/pqU7bTcfQ_s
Experiment to see the effect on graph height when the **plot bar graph** value ***up to*** is changed
**255 is the maximum light input reading**, try numbers smaller than 255 *graphing light input*
**Find a value** that allows the graph to show 1 - 5 bars https://youtu.be/pqU7bTcfQ_s
Experiment to see the effect on graph height when the **plot bar graph** value ***up to*** is changed
**255 is the maximum light input reading**, try numbers smaller than 255
**Find a value** that allows the graph to show 1 - 5 bars
### ~hint ### ~hint
### Frequency ### Frequency
**Frequency** measured in Hz which are cycles per second or vibrations per second **Frequency** measured in Hz which are cycles per second or vibrations per second
* A healthy human ear can detect frequencies in the range of 20Hz to 20,000Hz. * A healthy human ear can detect frequencies in the range of 20Hz to 20,000Hz.
* The micro:bit + headphones reliably produce detectable output ~50Hz - 6,000Hz. * The micro:bit + headphones reliably produce detectable output ~50Hz - 6,000Hz.
**261Hz** represents a C note **261Hz** represents a C note
```blocks ```blocks
music.playTone(261, music.beat(BeatFraction.Half)) music.playTone(261, music.beat(BeatFraction.Half))
``` ```
**play tone** blocks can specify a specific numeric **Frequency** **play tone** blocks can specify a numeric **Frequency**
by replacing the letter note 261Hz represents a **C** note with a **number** block by replacing the letter **C** note with a **number** block that has the value it represents
```blocks ```blocks
music.playTone(261, music.beat(BeatFraction.Half)) music.playTone(261, music.beat(BeatFraction.Half))
``` ```
### ~ ### ~
## Step 3: Multiply Frequency using Math blocks ## Step 3: Multiply Frequency using Math blocks
```blocks ```blocks
input.onButtonPressed(Button.A, () => { input.onButtonPressed(Button.A, () => {
music.playTone(261 * 2, music.beat(BeatFraction.Half)) music.playTone(261 * 2, music.beat(BeatFraction.Half))
}) })
``` ```
create a **play tone** block using a **Math** section, **multiplication** block to set *tone* Create a **play tone** block using a **Math** section, **multiplication** block to set *tone*
### Next ### Next
**Add** a **B** button block that multiplies the **261** tone by a number other than 2 to set tone **Add** a **B** button block that multiplies the **261** tone by a number other than 2 to set tone
**Download the code to the micro:bit** **Download the code to the micro:bit**
**Test the sound for multiples of the 261Hz *C* frequency**
**Test the sound for multiples of the 261Hz *C* frequency**
## Step 4: Control the Frequency with the light input ## Step 4: Control the Frequency with the light input
```blocks ```blocks
basic.forever(() => { basic.forever(() => {
music.playTone(input.lightLevel() * 25, music.beat(BeatFraction.Quarter)) music.playTone(input.lightLevel() * 25, music.beat(BeatFraction.Quarter))
}) })
``` ```
**Create a *forever loop* containing a *play tone* block** **Create a *forever loop* containing a *play tone* block**
**Set *tone*, using *Math* multiplication block that multiplies *light level* input by 25** **Set *tone*, using *Math* multiplication block that multiplies *light level* input by 25**
or experiment with multipliers larger and smaller than 25 or experiment with multipliers larger and smaller than 25
**Test light tone control on the guitar** **Test light tone control on the guitar**
Cover the LEDs with your hand to vary light detected to control the tone Cover the LEDs with your hand to vary light detected to control the tone
## Good work, this guitar is sounding good! ## Good work, this guitar is sounding good!
**Challenge:** Create a variable for the light level multiplier that you can change using buttons (optional) **Challenge:** Create a variable for the light level multiplier that you can change using buttons (optional)
### ~button /projects/guitar/accelerometer ### ~button /projects/guitar/accelerometer
NEXT: Accelerometer Beat control NEXT: Accelerometer Beat control
### ~ ### ~

View File

@ -1,5 +1,5 @@
# Making the Guitar Body # Making the Guitar Body
### @description Maker Project for Guitar Body for micro:bit ### @description Maker Project for Guitar Body for micro:bit
### ~avatar avatar ### ~avatar avatar
@ -11,9 +11,9 @@ Make the Guitar Body for your micro:bit Guitar
## Materials ## Materials
* Cardboard large pieces (recycle!) * Cardboard large pieces (recycle!)
* Tape (masking, duct Tape, and/or packing tape) * Tape (masking, duct tape, and/or packing tape)
* Scissors that can cut cardboard * Scissors that can cut cardboard
* Markers and/or paint * Markers and/or paint
![Materials: cardboard, tape, scissors, markers](/static/mb/projects/guitar/materials.jpg) ![Materials: cardboard, tape, scissors, markers](/static/mb/projects/guitar/materials.jpg)
@ -28,7 +28,7 @@ the shape of your guitar
### ~hint ### ~hint
* Avoid small details that are difficult to cut into cardboard * Avoid small details that are difficult to cut into cardboard
* Unfolding a box gives longer pieces of cardboard, and creases can be reinforced * Unfolding a box gives longer pieces of cardboard and creases can be reinforced
### ~ ### ~
@ -39,21 +39,21 @@ https://youtu.be/aUQkrFoEank
## Step 3: Personalize the Guitar ## Step 3: Personalize the Guitar
Create unique styling using tape, markers, paint and other available materials (*calling all artist!*) Create unique styles using tape, markers, paint and other available materials (*calling all artists!*)
*decorating the guitar* *decorating the guitar*
https://youtu.be/zNAZTJeSxY8 https://youtu.be/zNAZTJeSxY8
Everyone can come up with a unique design! Everyone can come up with a unique design!
![guitar design samples](/static/mb/projects/guitar/otherdesigns.jpg) ![guitar design samples](/static/mb/projects/guitar/otherdesigns.jpg)
## Extra! ## Extra!
*strengthening the guitar* *strengthening the guitar*
https://youtu.be/q0GkQdJmxjE https://youtu.be/q0GkQdJmxjE
Strengthen the guitar next with an angled cardboard strip (*optional*). Strengthen the guitar next with an angled cardboard strip (*optional*).
### ~button /projects/guitar/displaybuttons ### ~button /projects/guitar/displaybuttons
NEXT: Buttons, Display and Sound NEXT: Buttons, Display and Sound
### ~ ### ~

View File

@ -6,16 +6,16 @@
Use pin press to switch guitar play on/off Use pin press to switch guitar play on/off
* Concepts: * Concepts:
* Circuit * Circuit
* Conductor * Conductor
* Variable/Global-Variable * Variable/Global-Variable
* Conditional: **`if`**, **`else`** * Conditional: **`if`**, **`else`**
* Boolean: **`True`/`False`** * Boolean: **`True`/`False`**
### ~ ### ~
## Duration: approximately 45 minutes ## Duration: approximately 45 minutes
## Materials: ## Materials:
2-3 Crocodile clips 2-3 Crocodile clips
## Blocks ## Blocks
@ -31,16 +31,16 @@ input.onPinPressed(TouchPin.P1, () => {})
### ~hint ### ~hint
## Circuits & Switches ## Circuits & Switches
* **Circuits** need a power supply (battery), a resister (like a LED) & a conductor (metal, water, hand) * **Circuits** need a power supply (battery), a resister (like a LED) & a conductor (metal, water, hand)
* **Switches** turn electric power on by closing (completing) a circuit with a conductor so power can flow * **Switches** turn electric power on by closing (completing) a circuit with a conductor so power can flow
**Metal foil and wires make excellent conductors** **Metal foil and wires make excellent conductors**
**In this activity we use YOU to conduct electricity** **In this activity we use YOU to conduct electricity**
**to close the circuit that switches the guitar ON and OFF!** **to close the circuit that switches the guitar ON and OFF!**
### ~ ### ~
## Step 1: Pin Press Test ## Step 1: Pin Press Test
```blocks ```blocks
input.onPinPressed(TouchPin.P0, () => { input.onPinPressed(TouchPin.P0, () => {
@ -52,34 +52,34 @@ input.onPinPressed(TouchPin.P1, () => {
input.onPinPressed(TouchPin.P2, () => { input.onPinPressed(TouchPin.P2, () => {
basic.showNumber(2) basic.showNumber(2)
}) })
``` ```
**Create the pin-press code** **Create the pin-press code**
**Download the code** on the micro:bit **Download the code** on the micro:bit
https://youtu.be/PAIU-vHqyGU https://youtu.be/PAIU-vHqyGU
**Hold the micro:bit touching The GND pin with one hand**
**with the other hand alternately touch the 0, 1 and 2 pins**
**Hold the micro:bit touching The GND pin with one hand**
**with the other hand alternately touch the 0, 1 and 2 pins**
### ~hint ### ~hint
**The electric signal traveled from pins, between your hands to `GND` and the micro:bit detected the electric signal!** **The electric signal traveled from pins, between your hands to `GND` and the micro:bit detected the electric signal!**
### ~ ### ~
## Step 2: Installing conductive foil on the guitar
https://youtu.be/NX0ECcpXFes
**Add foil to the guitar body where it is easy to touch while playing**
**Connect the foil to `GND` using a crocodile clip** ## Step 2: Installing conductive foil on the guitar
https://youtu.be/NX0ECcpXFes
**Add foil to the guitar body where it is easy to touch while playing**
https://youtu.be/YkymZGNmkrE **Connect the foil to `GND` using a crocodile clip**
**Add foil to the guitar neck**
**Connect the foil to `pin 1` using a crocodile clip**
## Step 3: Add a switch to turn the guitar ON and OFF https://youtu.be/YkymZGNmkrE
**Using the `on` global variable we can switch the message on the micro:bit** **Add foil to the guitar neck**
**between ON and OFF**
**Connect the foil to `pin 1` using a crocodile clip**
## Step 3: Add a switch to turn the guitar ON and OFF
**Using the `on` global variable we can switch the message on the micro:bit**
**between ON and OFF**
```blocks ```blocks
let on = false let on = false
basic.forever(() => { basic.forever(() => {
@ -96,11 +96,11 @@ input.onPinPressed(TouchPin.P1, () => {
on = true on = true
} }
}) })
``` ```
**Create the ON/OFF switch code** **Create the ON/OFF switch code**
**Download the code on the micro:bit**
**Download the code on the micro:bit**
**Test by touching `P1` to toggle the LED message between ON and OFF** **Test by touching `P1` to toggle the LED message between ON and OFF**
*Final code* *Final code*
@ -123,9 +123,9 @@ basic.forever(() => {
input.onPinPressed(TouchPin.P1, () => { input.onPinPressed(TouchPin.P1, () => {
on = !on; on = !on;
}) })
``` ```
## Now Play! ## Now Play!
**Turn the guitar ON and OFF with a pin press on the connected foil** **Turn the guitar ON and OFF with a pin press on the connected foil by**
**touching both pieces of foil at the same time to connect the switches** **touching both pieces of foil at the same time to connect the switches**
https://youtu.be/GYmdTFvxz80 https://youtu.be/GYmdTFvxz80