Skip to content

Commit babfba1

Browse files
docs: Include V2 features in tutorials (#709)
* docs: update-tutorials for V2 * docs: update images * remove pin functions reference link * reduce size of image * Update docs/pin.rst * Update docs/pin.rst * Update docs/tutorials/io.rst Co-authored-by: Carlos Pereira Atencio <[email protected]>
1 parent f1de140 commit babfba1

File tree

8 files changed

+60
-35
lines changed

8 files changed

+60
-35
lines changed

docs/tutorials/blue-microbit.png

32 KB
Loading

docs/tutorials/happy.png

11.7 KB
Loading

docs/tutorials/images.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ display is a part of the ``Image`` object and called ``HAPPY``. We tell
1818
``show`` to use it by putting it between the parenthesis (``(`` and ``)``).
1919

2020
.. image:: happy.png
21+
:width: 300px
22+
:align: center
2123

2224
Here's a list of the built-in images:
2325

docs/tutorials/io.rst

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
1-
Input/Output
2-
------------
1+
Input/Output Pins
2+
-----------------
33

44
There are strips of metal along the bottom edge of the BBC micro:bit that make
55
it look as if the device has teeth. These are the input/output pins (or I/O pins
66
for short).
77

88
.. image:: blue-microbit.png
9+
:width: 300px
10+
:align: center
11+
:alt: micro:bit with pins labelled
912

1013
Some of the pins are bigger than others so it's possible to attach crocodile
1114
clips to them. These are the ones labelled 0, 1, 2, 3V and GND (computers
1215
always start counting from zero). If you attach an edge connector board to the
1316
device it's possible to plug in wires connected to the other (smaller) pins.
1417

15-
Each pin on the BBC micro:bit is represented by an *object* called ``pinN``
16-
where ``N`` is the pin number. So, for example, to do things with the pin
17-
labelled with a 0 (zero), use the object called ``pin0``.
18+
On the latest micro:bit **V2** the micro:bit logo can also be used as a touch
19+
input.
1820

19-
Simple!
21+
In MicroPython, each pin on the BBC micro:bit is represented by an *object*
22+
called ``pinN``, where ``N`` is the number pf the pin.
23+
24+
For example, to use the pin labelled 0 (zero), you can use the object called
25+
``pin0`` in your script. The logo pin **V2** uses ``pin_logo``.
2026

2127
These objects have various *methods* associated with them depending upon what
22-
the specific pin is capable of.
28+
the specific pin is capable of eg. read, write or touch.
2329

2430
Ticklish Python
2531
+++++++++++++++
2632

2733
The simplest example of input via the pins is a check to see if they are
28-
touched. So, you can tickle your device to make it laugh like this::
34+
touched. So, you can tickle your micro:bit to make it laugh like this::
2935

3036
from microbit import *
3137

@@ -35,26 +41,46 @@ touched. So, you can tickle your device to make it laugh like this::
3541
else:
3642
display.show(Image.SAD)
3743

38-
With one hand, hold your device by the GND pin. Then, with your other hand,
44+
With one hand, hold your micro:bit by the GND pin. Then, with your other hand,
3945
touch (or tickle) the 0 (zero) pin. You should see the display change from
4046
grumpy to happy!
4147

48+
When you use the latest micro:bit **V2** you can also change the default
49+
behaviour of the pin, so that you don't have to touch GND at all.::
50+
51+
from microbit import *
52+
pin0.set_touch_mode(pin0.CAPACITIVE)
53+
while True:
54+
if pin0.is_touched():
55+
display.show(Image.HAPPY)
56+
else:
57+
display.show(Image.SAD)
58+
59+
The default for the edge connector pins is `resistive` and the logo pin
60+
**V2** is `capacitive`.
61+
4262
This is a form of very basic input measurement. However, the fun really starts
4363
when you plug in circuits and other devices via the pins.
4464

4565
Bleeps and Bloops
4666
+++++++++++++++++
4767

48-
The simplest thing we can attach to the device is a Piezo buzzer. We're going
68+
The simplest thing we can attach to the micro:bit is a Piezo buzzer. We're going
4969
to use it for output.
5070

5171
.. image:: piezo_buzzer.jpg
72+
:width: 250px
73+
:align: center
74+
:alt: piezo buzzer
5275

5376
These small devices play a high-pitched bleep when connected to a circuit. To
5477
attach one to your BBC micro:bit you should attach crocodile clips to pin 0 and
55-
GND (as shown below).
78+
GND.
5679

5780
.. image:: pin0-gnd.png
81+
:width: 250px
82+
:align: center
83+
:alt: piezo connected to pin0 and GND
5884

5985
The wire from pin 0 should be attached to the positive connector on the buzzer
6086
and the wire from GND to the negative connector.

docs/tutorials/music.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@ Music
22
-----
33

44
MicroPython on the BBC micro:bit comes with a powerful music and sound module.
5-
It's very easy to generate bleeps and bloops from the device *if you attach a
6-
speaker*. Use crocodile clips to attach pin 0 and GND to the positive and
7-
negative inputs on the speaker - it doesn't matter which way round they are
8-
connected to the speaker.
5+
It's very easy to generate bleeps and bloops from the device by attaching a
6+
speaker or set of wired headphones, or by using the built-in speaker **V2**.
7+
8+
If you are attaching a speaker/headphones, you can use crocodile clips to
9+
attach pin 0 and GND to the positive and negative inputs on the speaker.
910

1011
.. image:: pin0-gnd.png
12+
:width: 250px
13+
:align: center
14+
:alt: piezo connected to pin0 and GND
1115

1216
.. note::
1317

14-
Do not attempt this with a Piezo buzzer - such buzzers are only able to
15-
play a single tone.
18+
Do not attempt this with an active Piezo buzzer - such buzzers are only
19+
able to play a single tone.
1620

1721
Let's play some music::
1822

docs/tutorials/piezo_buzzer.jpg

-114 KB
Loading

docs/tutorials/pin0-gnd.png

25.9 KB
Loading

docs/tutorials/speech.rst

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
Speech
22
------
33

4-
.. warning::
5-
6-
WARNING! THIS IS ALPHA CODE.
7-
8-
We reserve the right to change this API as development continues.
9-
10-
The quality of the speech is not great, merely "good enough". Given the
11-
constraints of the device you may encounter memory errors and / or
12-
unexpected extra sounds during playback. It's early days and we're
13-
improving the code for the speech synthesiser all the time. Bug reports
14-
and pull requests are most welcome.
15-
164
Computers and robots that talk feel more "human".
175

186
So often we learn about what a computer is up to through a graphical user
@@ -42,9 +30,14 @@ In any case, we're going to create a DALEK poetry recital on demand.
4230
Say Something
4331
+++++++++++++
4432

45-
Before the device can talk you need to plug in a speaker like this:
33+
If you have the latest micro:bit **V2** device, you can use the built-in
34+
speaker as well as or instead of connecting a speaker or set of headphones
35+
like this:
4636

47-
.. image:: ../speech.png
37+
.. image:: pin0-gnd.png
38+
:width: 250px
39+
:align: center
40+
:alt: piezo connected to pin0 and GND
4841

4942
The simplest way to get the device to speak is to import the ``speech`` module
5043
and use the ``say`` function like this::
@@ -58,10 +51,10 @@ change some of the parameters that the speech synthesiser uses to produce the
5851
voice. Our speech synthesiser is quite powerful in this respect because we can
5952
change four parameters:
6053

61-
* ``pitch`` - how high or low the voice sounds (0 = high, 255 = Barry White)
62-
* ``speed`` - how quickly the device talks (0 = impossible, 255 = bedtime story)
63-
* ``mouth`` - how tight-lipped or overtly enunciating the voice sounds (0 = ventriloquist's dummy, 255 = Foghorn Leghorn)
64-
* ``throat`` - how relaxed or tense is the tone of voice (0 = falling apart, 255 = totally chilled)
54+
* ``pitch`` - how high or low the voice sounds (0 = high, 255 = low)
55+
* ``speed`` - how quickly the device talks (0 = fast, 255 = slow)
56+
* ``mouth`` - how tight-lipped or overtly enunciating the voice sounds (0 = closed mouth, 255 = open mouth)
57+
* ``throat`` - how relaxed or tense is the tone of voice (0 = tense, 255 = relaxed)
6558

6659
Collectively, these parameters control the quality of sound - a.k.a. the
6760
timbre. To be honest, the best way to get the tone of voice you want is to

0 commit comments

Comments
 (0)