pxt-calliope/docs/projects/guitar/pinpress.md

131 lines
3.1 KiB
Markdown
Raw Normal View History

2016-09-27 06:55:39 +02:00
# Pin Press Switch
2016-11-02 01:44:37 +01:00
### @description @boardname@ guitar: use pin press to toggle guitar play on/off
2016-09-27 06:55:39 +02:00
### ~avatar avatar
Use pin press to switch guitar play on/off
Updated guitar lessons (#268) * initial notes * updated code samples * splitting the page and preparing layout * missing gamepad api * added basic guitar activty md files added initial draft of guitar lesson - in progress * word smithing and adding detail for concepts listed * word smithing and adding detail for concepts listed * typo in file name * missing macro * replaced guitar.png with image from Julia Carlson * adding a few pictures * adding cards macros * few tweaks * image for accellerometer lesson xyz axis * fixed the numbering buttons page -fixed the numbering to restart for each section and asdded spaces after so they don't wrap * adding a few video links * pin-press - added circuit info * more vids * fixing latest commit * edits to light sensor and pin-press * updated descriptions, linking lesson * pin-press and display-buttons updates -added dode samples to pin press * updated making video * light-sensor updated numbering * Clean up Clean up of headings to template style, other fixes * putting display in template use h2 with "Step 1:" and image before text * removed numbered lists for display & light these topics are code complete * more consistent formating Acceleromenter, buttons, light sensosr * Acceleration Lesson, added art Lesson steps for Acceleration, art for degree F to C for Map anology+clean up of light sensor topic * Pin Press code complete some other basic fomats and edits * Removed dashes in lesson names renamed and fixed references to files with "-" in names * rest of fles w/ dash in name changes * fixed links to guitar activities * updated acceleraomter section * transparency 4 art, image text added transarency and renamed art, added descriptive text for video and still images * renamed art * fixing the merge * fixing hint * moved step 2 outside ~hint block * fixing snippets * remove guitar from project list * Duration/Materials consistent format moved out of ~avatar block
2016-10-03 23:59:58 +02:00
2016-09-27 06:55:39 +02:00
* Concepts:
2016-10-04 01:37:13 +02:00
* Circuit
* Conductor
* Variable/Global-Variable
* Conditional: **`if`**, **`else`**
2016-09-27 06:55:39 +02:00
* Boolean: **`True`/`False`**
2016-10-04 01:37:13 +02:00
### ~
Updated guitar lessons (#268) * initial notes * updated code samples * splitting the page and preparing layout * missing gamepad api * added basic guitar activty md files added initial draft of guitar lesson - in progress * word smithing and adding detail for concepts listed * word smithing and adding detail for concepts listed * typo in file name * missing macro * replaced guitar.png with image from Julia Carlson * adding a few pictures * adding cards macros * few tweaks * image for accellerometer lesson xyz axis * fixed the numbering buttons page -fixed the numbering to restart for each section and asdded spaces after so they don't wrap * adding a few video links * pin-press - added circuit info * more vids * fixing latest commit * edits to light sensor and pin-press * updated descriptions, linking lesson * pin-press and display-buttons updates -added dode samples to pin press * updated making video * light-sensor updated numbering * Clean up Clean up of headings to template style, other fixes * putting display in template use h2 with "Step 1:" and image before text * removed numbered lists for display & light these topics are code complete * more consistent formating Acceleromenter, buttons, light sensosr * Acceleration Lesson, added art Lesson steps for Acceleration, art for degree F to C for Map anology+clean up of light sensor topic * Pin Press code complete some other basic fomats and edits * Removed dashes in lesson names renamed and fixed references to files with "-" in names * rest of fles w/ dash in name changes * fixed links to guitar activities * updated acceleraomter section * transparency 4 art, image text added transarency and renamed art, added descriptive text for video and still images * renamed art * fixing the merge * fixing hint * moved step 2 outside ~hint block * fixing snippets * remove guitar from project list * Duration/Materials consistent format moved out of ~avatar block
2016-10-03 23:59:58 +02:00
2016-10-04 01:37:13 +02:00
## Duration: approximately 45 minutes
Updated guitar lessons (#268) * initial notes * updated code samples * splitting the page and preparing layout * missing gamepad api * added basic guitar activty md files added initial draft of guitar lesson - in progress * word smithing and adding detail for concepts listed * word smithing and adding detail for concepts listed * typo in file name * missing macro * replaced guitar.png with image from Julia Carlson * adding a few pictures * adding cards macros * few tweaks * image for accellerometer lesson xyz axis * fixed the numbering buttons page -fixed the numbering to restart for each section and asdded spaces after so they don't wrap * adding a few video links * pin-press - added circuit info * more vids * fixing latest commit * edits to light sensor and pin-press * updated descriptions, linking lesson * pin-press and display-buttons updates -added dode samples to pin press * updated making video * light-sensor updated numbering * Clean up Clean up of headings to template style, other fixes * putting display in template use h2 with "Step 1:" and image before text * removed numbered lists for display & light these topics are code complete * more consistent formating Acceleromenter, buttons, light sensosr * Acceleration Lesson, added art Lesson steps for Acceleration, art for degree F to C for Map anology+clean up of light sensor topic * Pin Press code complete some other basic fomats and edits * Removed dashes in lesson names renamed and fixed references to files with "-" in names * rest of fles w/ dash in name changes * fixed links to guitar activities * updated acceleraomter section * transparency 4 art, image text added transarency and renamed art, added descriptive text for video and still images * renamed art * fixing the merge * fixing hint * moved step 2 outside ~hint block * fixing snippets * remove guitar from project list * Duration/Materials consistent format moved out of ~avatar block
2016-10-03 23:59:58 +02:00
2016-10-04 01:37:13 +02:00
## Materials:
Updated guitar lessons (#268) * initial notes * updated code samples * splitting the page and preparing layout * missing gamepad api * added basic guitar activty md files added initial draft of guitar lesson - in progress * word smithing and adding detail for concepts listed * word smithing and adding detail for concepts listed * typo in file name * missing macro * replaced guitar.png with image from Julia Carlson * adding a few pictures * adding cards macros * few tweaks * image for accellerometer lesson xyz axis * fixed the numbering buttons page -fixed the numbering to restart for each section and asdded spaces after so they don't wrap * adding a few video links * pin-press - added circuit info * more vids * fixing latest commit * edits to light sensor and pin-press * updated descriptions, linking lesson * pin-press and display-buttons updates -added dode samples to pin press * updated making video * light-sensor updated numbering * Clean up Clean up of headings to template style, other fixes * putting display in template use h2 with "Step 1:" and image before text * removed numbered lists for display & light these topics are code complete * more consistent formating Acceleromenter, buttons, light sensosr * Acceleration Lesson, added art Lesson steps for Acceleration, art for degree F to C for Map anology+clean up of light sensor topic * Pin Press code complete some other basic fomats and edits * Removed dashes in lesson names renamed and fixed references to files with "-" in names * rest of fles w/ dash in name changes * fixed links to guitar activities * updated acceleraomter section * transparency 4 art, image text added transarency and renamed art, added descriptive text for video and still images * renamed art * fixing the merge * fixing hint * moved step 2 outside ~hint block * fixing snippets * remove guitar from project list * Duration/Materials consistent format moved out of ~avatar block
2016-10-03 23:59:58 +02:00
2-3 Crocodile clips
2016-09-27 06:55:39 +02:00
## Blocks
```cards
var on = false
on;
if (on) { } else {}
input.onPinPressed(TouchPin.P1, () => {})
```
### ~hint
## Circuits & Switches
2016-10-04 01:37:13 +02:00
* **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
2016-09-27 06:55:39 +02:00
2016-10-04 01:37:13 +02:00
**Metal foil and wires make excellent conductors**
2016-09-27 06:55:39 +02:00
2016-10-04 01:37:13 +02:00
**In this activity we use YOU to conduct electricity**
**to close the circuit that switches the guitar ON and OFF!**
2016-09-27 06:55:39 +02:00
### ~
2016-10-04 01:37:13 +02:00
## Step 1: Pin Press Test
2016-09-27 06:55:39 +02:00
```blocks
input.onPinPressed(TouchPin.P0, () => {
basic.showNumber(0)
})
input.onPinPressed(TouchPin.P1, () => {
basic.showNumber(1)
})
input.onPinPressed(TouchPin.P2, () => {
basic.showNumber(2)
})
2016-10-04 01:37:13 +02:00
```
**Create the pin-press code**
2016-09-27 06:55:39 +02:00
2016-11-02 01:44:37 +01:00
**Download the code** on the @boardname@
2016-09-27 06:55:39 +02:00
2016-10-04 01:37:13 +02:00
https://youtu.be/PAIU-vHqyGU
2016-11-02 01:44:37 +01:00
**Hold the @boardname@ touching The GND pin with one hand**
2016-10-04 01:37:13 +02:00
**with the other hand alternately touch the 0, 1 and 2 pins**
2016-09-27 06:55:39 +02:00
### ~hint
2016-11-02 01:44:37 +01:00
**The electric signal traveled from pins, between your hands to `GND` and the @boardname@ detected the electric signal!**
2016-10-04 01:37:13 +02:00
### ~
## 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**
https://youtu.be/YkymZGNmkrE
**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
2016-11-02 01:44:37 +01:00
**Using the `on` global variable we can switch the message on the @boardname@**
2016-10-04 01:37:13 +02:00
**between ON and OFF**
2016-09-27 06:55:39 +02:00
```blocks
let on = false
basic.forever(() => {
if (on == true) {
basic.showString("ON")
} else {
basic.showString("OFF")
}
})
input.onPinPressed(TouchPin.P1, () => {
if (on == true) {
on = false
} else {
on = true
}
})
2016-10-04 01:37:13 +02:00
```
**Create the ON/OFF switch code**
2016-11-02 01:44:37 +01:00
**Download the code on the @boardname@**
2016-09-27 06:55:39 +02:00
**Test by touching `P1` to toggle the LED message between ON and OFF**
*Final code*
TODO: do we want to use `on = !on;` or be more direct in flipping the switch? `on = true; on = false;`
```blocks
var on = false
basic.forever(() => {
if (on) {
music.setTempo(pins.map(Math.abs(input.acceleration(Dimension.Y)),
0, 1023,
60, 320))
music.playTone(
input.lightLevel() * 25,
music.beat(BeatFraction.Quarter)
);
} else {
music.rest(music.beat())
}
})
input.onPinPressed(TouchPin.P1, () => {
on = !on;
})
2016-10-04 01:37:13 +02:00
```
## Now Play!
**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**
https://youtu.be/GYmdTFvxz80