Skip to content

Commit af8f33f

Browse files
docs: Include V2 features in tutorials (bbcmicrobit#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 dc722f3 commit af8f33f

File tree

6 files changed

+33
-20
lines changed

6 files changed

+33
-20
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: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,21 @@ for short).
88
.. image:: blue-microbit.png
99
:width: 300px
1010
:align: center
11+
:alt: micro:bit with pins labelled
1112

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

18+
On the latest micro:bit **V2** the micro:bit logo can also be used as a touch
19+
input.
20+
1721
In MicroPython, each pin on the BBC micro:bit is represented by an *object*
1822
called ``pinN``, where ``N`` is the number pf the pin.
1923

2024
For example, to use the pin labelled 0 (zero), you can use the object called
21-
``pin0`` in your script.
25+
``pin0`` in your script. The logo pin **V2** uses ``pin_logo``.
2226

2327
These objects have various *methods* associated with them depending upon what
2428
the specific pin is capable of eg. read, write or touch.
@@ -41,6 +45,20 @@ With one hand, hold your micro:bit by the GND pin. Then, with your other hand,
4145
touch (or tickle) the 0 (zero) pin. You should see the display change from
4246
grumpy to happy!
4347

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+
4462
This is a form of very basic input measurement. However, the fun really starts
4563
when you plug in circuits and other devices via the pins.
4664

docs/tutorials/music.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Music
33

44
MicroPython on the BBC micro:bit comes with a powerful music and sound module.
55
It's very easy to generate bleeps and bloops from the device by attaching a
6-
speaker or set of wired headphones.
6+
speaker or set of wired headphones, or by using the built-in speaker **V2**.
77

88
If you are attaching a speaker, a passive piezo buzzer, or headphones, you can
99
use crocodile clips to attach pin 0 and GND to the positive and negative inputs.

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)