pxt-microbit 5.0.12 → 5.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/built/editor.js +36 -2
  2. package/built/target-strings.json +5 -0
  3. package/built/target.js +46 -36
  4. package/built/target.json +46 -36
  5. package/built/targetlight.json +5 -5
  6. package/built/theme.json +11 -0
  7. package/built/web/react-common-authcode.css +6 -2
  8. package/built/web/react-common-skillmap.css +1 -1
  9. package/built/web/rtlreact-common-skillmap.css +1 -1
  10. package/built/web/rtlsemantic.css +1 -1
  11. package/built/web/semantic.css +1 -1
  12. package/docs/SUMMARY.md +2 -0
  13. package/docs/device/pins.md +72 -40
  14. package/docs/extensions.md +8 -0
  15. package/docs/jacdac.md +60 -0
  16. package/docs/projects/SUMMARY.md +10 -0
  17. package/docs/projects/games.md +6 -0
  18. package/docs/projects/magic-button-trick.md +0 -2
  19. package/docs/projects/rock-paper-scissors-v2.md +201 -0
  20. package/docs/projects/v2-cat-napping.md +219 -0
  21. package/docs/projects.md +6 -0
  22. package/docs/reference/input/logo-is-pressed.md +1 -1
  23. package/docs/reference/input/on-logo-event.md +1 -1
  24. package/docs/reference/serial/on-data-received.md +1 -1
  25. package/docs/reference/serial/read-buffer.md +8 -7
  26. package/docs/reference/serial/read-line.md +8 -6
  27. package/docs/reference/serial/read-string.md +4 -4
  28. package/docs/reference/serial/read-until.md +4 -4
  29. package/docs/reference/serial/redirect.md +8 -7
  30. package/docs/reference/serial/set-baud-rate.md +56 -0
  31. package/docs/reference/serial/set-write-line-padding.md +51 -0
  32. package/docs/reference/serial/write-buffer.md +4 -4
  33. package/docs/reference/serial/write-line.md +6 -6
  34. package/docs/reference/serial/write-number.md +6 -6
  35. package/docs/reference/serial/write-numbers.md +6 -6
  36. package/docs/reference/serial/write-string.md +5 -5
  37. package/docs/reference/serial/write-value.md +3 -3
  38. package/docs/reference/serial.md +4 -1
  39. package/docs/tutorials-v2.md +6 -0
  40. package/package.json +2 -2
  41. package/pxtarget.json +1 -0
  42. package/targetconfig.json +9 -4
@@ -0,0 +1,219 @@
1
+ # Cat Napping
2
+
3
+ ## 1. Introduction @unplugged
4
+
5
+ Lychee the cat loves the sun and wants to know if your home has a good sunbathing spot. Are you up for the challenge?
6
+
7
+ ![Cat Tanning banner message, an image of a cat](/static/mb/projects/cat-napping/1_lychee.png)
8
+
9
+ ## 2. Setting logging to false on start
10
+
11
+ 📋 **Variable data** 📋
12
+
13
+ First, we want to make sure we know when our micro:bit is collecting data. To do this, let's create a [__*boolean*__](#boolean "something that is only true or false") [__*variable*__](#variable "a holder for information that may change") and use it to track when the @boardname@ is logging data. We'll start with the logging variable set to false.
14
+
15
+ ---
16
+
17
+ ► In the ``||variables:Variables||`` category, click on ``Make a Variable...`` and make a variable named ``logging``.
18
+
19
+ ► From the ``||variables:Variables||`` category, grab the ``||variables:set [logging] to [0]||`` block and snap it into the empty ``||basic:on start||`` container.
20
+
21
+ ► From the ``||logic:Logic||`` category, grab a ``||logic:<false>||`` argument and snap it in to **replace** the ``||variables:[0]||`` value in your ``||variables:set [logging] to [0]||`` statement.
22
+
23
+ ```blocks
24
+ let logging = false
25
+ logging = false
26
+ ```
27
+
28
+ ## 3. Toggle logging on A press
29
+
30
+ ▶️ **Starting and stopping** ⏸️
31
+
32
+ Let's give Lychee some control over when she wants to start and stop logging data on the @boardname@.
33
+
34
+ ---
35
+
36
+ ► From the ``||input:Input||`` category, grab a ``||input:on button [A] pressed||`` container and drag it into your workspace.
37
+
38
+ ► From the ``||variables:Variables||`` category, grab a ``||variables:set [logging] to [0]||`` block and snap it inside of your ``||input:on button [A] pressed||`` container.
39
+
40
+ ► From the ``||logic:Logic||`` category, grab a ``||logic:<not []>||`` argument and snap it in to **replace** the ``0`` argument.
41
+
42
+ ► From the ``||variables:Variables||`` category, grab a ``||variables:logging||`` variable and snap it in to **replace** the empty ``||logic:<>||`` in the ``||logic:not <>||`` statement.
43
+
44
+ ✋🛑 Take a moment to help Lychee answer the following question: _What is happening every time she presses the A button?_
45
+
46
+ ```blocks
47
+ let logging = false
48
+ input.onButtonPressed(Button.A, function () {
49
+ logging = !(logging)
50
+ })
51
+ ```
52
+
53
+ ## 4. Visual logging indicators
54
+
55
+ 👀 **Visual indicators** 👀
56
+
57
+ It would help to know when the @boardname@ is logging data and when it isn't. For this step, we will be building out a visual indicator using an [__*if then / else*__](#ifthenelse "runs some code if a boolean condition is true and different code if the condition is false") statement.
58
+
59
+ ---
60
+
61
+ ► From the ``||logic:Logic||`` category, grab an ``||logic:if <true> then / else||`` statement and snap it in at the **bottom** of your ``||input:on button [A] pressed||`` container.
62
+
63
+ ► From ``||variables:Variables||``, grab a ``||variables:logging||`` variable and snap it in to **replace** the ``||logic:<true>||`` condition in your ``||logic:if then / else||`` statement.
64
+
65
+ ► Let's display an image when the @boardname@ is logging data. From the ``||basic:Basic||`` category, grab a ``||basic:show icon []||`` block and snap it into the empty **top container** of your ``||logic:if then / else||`` statement.
66
+
67
+ ► Set it to show the "target" icon (it looks like an empty sun - scroll down to find it!). This will show whenever your @boardname@ is collecting data. <br />
68
+ 💡 In the ``show icon`` dropdown menu options, you can hover to see what each design is called.
69
+
70
+ ```blocks
71
+ let logging = false
72
+ input.onButtonPressed(Button.A, function () {
73
+ logging = !(logging)
74
+ if (logging) {
75
+ basic.showIcon(IconNames.Target)
76
+ } else {
77
+ }
78
+ })
79
+ ```
80
+
81
+ ## 4. Auditory logging indicators
82
+
83
+ Let's now add an auditory indicator that your @boardname@ is logging data!
84
+
85
+ ---
86
+
87
+ ► From the ``||music:Music||`` category, grab a ``||music:play sound [giggle] [until done]||`` block and snap it into the **bottom** of the **top container** of your ``||logic:if then / else||`` statement.
88
+
89
+ ► Click on the ``giggle`` dropdown and select ``hello``. Your block should now say ``||music:play sound [hello] [until done]||``.
90
+
91
+ ► Let's clear the board when the @boardname@ is not logging data. From the ``||basic:Basic||`` category, grab a ``||basic:clear screen||`` block and snap it into the empty **bottom container** of your ``||logic:if then / else||`` statement.
92
+
93
+ ```blocks
94
+ let logging = false
95
+ input.onButtonPressed(Button.A, function () {
96
+ logging = !(logging)
97
+ if (logging) {
98
+ basic.showIcon(IconNames.Target)
99
+ music.playSoundEffect(music.builtinSoundEffect(soundExpression.hello), SoundExpressionPlayMode.UntilDone)
100
+ } else {
101
+ basic.clearScreen()
102
+ }
103
+ })
104
+ ```
105
+
106
+ ## 5. Time interval for data logging
107
+
108
+ 📈 **A data point a minute** 📈
109
+
110
+ Let's set up the data logging for Lychee! In order to get Lychee a good amount of data without running out of memory, we should collect one data point for her every minute.
111
+
112
+ ---
113
+
114
+ ► From the ``||loops:Loops||`` category, grab a ``||loops:every [500] ms||`` container and add it to your workspace.
115
+
116
+ ► Click on the the ``500`` dropdown and select ``1 minute``. <br />
117
+ 💡 1 minute is equivalent to 60000ms, which is what the number will automatically change to.
118
+
119
+ ```blocks
120
+ loops.everyInterval(60000, function () {
121
+ })
122
+ ```
123
+
124
+ ## 6. Setting up a logging variable
125
+
126
+ Now, let's use an [__*if then*__](#ifthen "runs some code if a boolean condition is true") statement to track when the @boardname@ is logging data.
127
+
128
+ ---
129
+
130
+ ► From the ``||logic:Logic||`` category, grab a ``||logic:if <true> then||`` statement and snap it into your ``||loops:every [600000] ms||`` container.
131
+
132
+ ► From the ``||variables:Variables||`` category, drag out a ``||variables:logging||`` variable and snap it in to **replace** the ``||logic:<true>||`` argument in the ``||logic:if <true> then||`` statement.
133
+
134
+ ```blocks
135
+ let logging = false
136
+ loops.everyInterval(60000, function () {
137
+ if (logging) {
138
+ }
139
+ })
140
+ ```
141
+
142
+ ## 7. Setting up logging - Part 1
143
+
144
+ 🏁 **Ready...set...log!** 🏁
145
+
146
+ Lychee loves her sun spots because they provide a nice, sunny and warm place to nap. So, we'll need to measure the **temperature** and **light** in different places around the house.
147
+
148
+ ---
149
+
150
+ ► From the ``||datalogger:Data Logger||`` category, grab a ``||datalogger:log data [column [""] value [0]] +||`` block and snap it **inside** the ``||logic:if [logging] then||`` statement.
151
+
152
+ ► Click on the ``""`` after the word ``column`` and type in "``temp``".
153
+
154
+ ► From the ``||input:Input||`` category, select the ``||input:temperature (°C)||`` parameter and drag it in to **replace** the ``0`` after the word ``value``.
155
+
156
+ ```blocks
157
+ let logging = false
158
+ loops.everyInterval(60000, function () {
159
+ if (logging) {
160
+ //@highlight
161
+ datalogger.log(
162
+ datalogger.createCV("temp", input.temperature())
163
+ )
164
+ }
165
+ })
166
+ ```
167
+
168
+ ## 8. Setting up logging - Part 2
169
+
170
+ ► On the right of the ``||input:temperature (°C)||`` input that you just snapped in, there is a ➕ button. Click on it. You should now see a new row that says ``||datalogger:column [""] value [0]||``.
171
+
172
+ ► Click on the empty ``""`` after the word ``column`` and type in "``light``".
173
+
174
+ ► From the ``||input:Input||`` category, select the ``||input:light level||`` parameter and drag it in to **replace** the ``0`` parameter after the word ``value``.
175
+
176
+ ```blocks
177
+ let logging = false
178
+ loops.everyInterval(60000, function () {
179
+ if (logging) {
180
+ //@highlight
181
+ datalogger.log(
182
+ datalogger.createCV("temp", input.temperature()),
183
+ datalogger.createCV("light", input.lightLevel())
184
+ )
185
+ }
186
+ })
187
+ ```
188
+
189
+ ## 9. Time to log data! @unplugged
190
+
191
+ 🎉 **Time to log data!** 🎉
192
+
193
+ You did it! If you have a @boardname@ V2 (the one with the **shiny gold** logo at the top), download this code and try it out!
194
+
195
+ ---
196
+
197
+ ► Find a sun spot in your house and press the ``A`` button to start logging data - your display should show an icon and play a sound to indicate that you are logging data.
198
+
199
+ ► After some time (we recommend at least an hour), press the ``A`` button again to stop logging data - your display should clear to indicate that you are not logging data.
200
+
201
+ ## 10. Reviewing your data @unplugged
202
+
203
+ 🕵️ **Reviewing your data** 🕵️
204
+
205
+ Now that you have logged some data, plug your @boardname@ into a laptop or desktop computer. The @boardname@ will appear like a USB drive called MICROBIT. Look in there and you'll see a file called MY_DATA:
206
+
207
+ ![MY_DATA file highlighted in file folder](/static/mb/projects/cat-napping/11_mydata.png)
208
+
209
+ Double-click on MY_DATA to open it in a web browser and you'll see a table with your data:
210
+
211
+ ![Image of sample data file](/static/mb/projects/cat-napping/11_datafile.png)
212
+
213
+ ## 11. Lychee's preferences @unplugged
214
+
215
+ Does your home have a good sunbathing spot for Lychee? Compare the light and temperature levels you record for different areas around your house! The sunniest and warmest spots will likely be her favorite ☀️😻
216
+
217
+ ```package
218
+ datalogger
219
+ ```
package/docs/projects.md CHANGED
@@ -68,6 +68,11 @@
68
68
  "url": "/courses",
69
69
  "imageUrl": "/static/courses/csintro.jpg"
70
70
  },
71
+ {
72
+ "name": "Jacdac",
73
+ "url": "/jacdac",
74
+ "imageUrl": "/static/jacdac/getting-started.jpg"
75
+ },
71
76
  {
72
77
  "name": "Behind the MakeCode Hardware",
73
78
  "url": "/behind-the-makecode-hardware",
@@ -111,6 +116,7 @@
111
116
  [Turtle](/projects/turtle),
112
117
  [Blocks to JavaScript](/courses/blocks-to-javascript),
113
118
  [Courses](/courses),
119
+ [Jacdac](/jacdac),
114
120
  [Behind the MakeCode Hardware](/behind-the-makecode-hardware),
115
121
  [Science Experiments](/science-experiments),
116
122
  [Coding for Teachers](/coding-for-teachers),
@@ -39,4 +39,4 @@ basic.forever(function () {
39
39
  [micro:bit V2](/device/v2),
40
40
  [on logo event](/reference/input/on-logo-event),
41
41
  [pin is pressed](/referene/inpu/pin-is-pressed),
42
- [touch set mode](/referene/inpu/touch-set-mode)
42
+ [touch set mode](/reference/pins/touch-set-mode)
@@ -35,4 +35,4 @@ input.onLogoEvent(TouchButtonEvent.Pressed, function () {
35
35
  [micro:bit V2](/device/v2),
36
36
  [logo is pressed](/reference/input/logo-is-pressed),
37
37
  [on pin pressed](/reference/input/on-logo-released),
38
- [touch set mode](/referene/inpu/touch-set-mode)
38
+ [touch set mode](/reference/pins/touch-set-mode)
@@ -4,7 +4,7 @@ Registers an event to be fired when one of the delimiter is matched.
4
4
 
5
5
 
6
6
  ```sig
7
- serial.onDataReceived(",", () => {})
7
+ serial.onDataReceived(",", function() {})
8
8
  ```
9
9
 
10
10
  ## Parameters
@@ -3,7 +3,7 @@
3
3
  Read available serial data into a buffer.
4
4
 
5
5
  ```sig
6
- serial.readBuffer(64);
6
+ serial.readBuffer(64)
7
7
  ```
8
8
 
9
9
  ## Parameters
@@ -16,13 +16,15 @@ Use ``0`` to return the available buffered data.
16
16
  * a [buffer](/types/buffer) containing input from the serial port. The length of the buffer may be smaller than the requested length.
17
17
  The length is 0 if any error occurs.
18
18
 
19
- ## ~hint
20
- **Pause for more data**
19
+ ### ~ hint
20
+
21
+ #### Pause for more data
21
22
 
22
23
  If the desired number of characters are available, **readBuffer** returns a buffer with the expected size. If not, the calling fiber (the part of your program calling the **readBuffer** function) sleeps until the desired number of characters are finally read into the buffer.
23
24
 
24
25
  To avoid waiting for data, set the length to ``0`` so that buffered data is returned immediately.
25
- ## ~
26
+
27
+ ### ~
26
28
 
27
29
  ## Example
28
30
 
@@ -31,7 +33,7 @@ Read character data from the serial port one row at a time. Write the rows to an
31
33
  ```typescript
32
34
  serial.setRxBufferSize(10)
33
35
  for (let i = 0; i < 24; i++) {
34
- let rowData = serial.readBuffer(10);
36
+ let rowData = serial.readBuffer(10)
35
37
  pins.i2cWriteBuffer(65, rowData, false);
36
38
  }
37
39
  ```
@@ -42,14 +44,13 @@ Read available data and process it as it comes.
42
44
 
43
45
  ```typescript
44
46
  basic.forever(function() {
45
- let rowData = serial.readBuffer(0);
47
+ let rowData = serial.readBuffer(0)
46
48
  if (rowData.length > 0) {
47
49
  // do something!!!
48
50
  }
49
51
  })
50
52
  ```
51
53
 
52
-
53
54
  ## See Also
54
55
 
55
56
  [write buffer](/reference/serial/write-buffer)
@@ -3,13 +3,15 @@
3
3
  Read a line of text from the serial port.
4
4
 
5
5
  ```sig
6
- serial.readLine();
6
+ serial.readLine()
7
7
  ```
8
8
 
9
9
  ### ~hint
10
10
 
11
+ #### Newline characters
12
+
11
13
  This function expects the line it reads to be terminated with the `\n`
12
- character. If your terminal software does not terminate lines with
14
+ character. If your terminal software does not terminate lines with
13
15
  `\n`, this function will probably never return a value.
14
16
 
15
17
 
@@ -27,11 +29,11 @@ The following example requests the user's name, then repeats it to greet the use
27
29
 
28
30
  ```blocks
29
31
  basic.forever(() => {
30
- serial.writeLine("What is your name?");
32
+ serial.writeLine("What is your name?")
31
33
  let answer = serial.readLine();
32
- serial.writeString("Hello,");
33
- serial.writeLine(answer);
34
- });
34
+ serial.writeString("Hello,")
35
+ serial.writeLine(answer)
36
+ })
35
37
  ```
36
38
 
37
39
  ## See also
@@ -3,7 +3,7 @@
3
3
  Read the buffered serial data as a string.
4
4
 
5
5
  ```sig
6
- serial.readString();
6
+ serial.readString()
7
7
  ```
8
8
 
9
9
  ## Returns
@@ -15,9 +15,9 @@ serial.readString();
15
15
  The following program scrolls text on the screen as it arrives from serial.
16
16
 
17
17
  ```blocks
18
- basic.forever(() => {
19
- basic.showString(serial.readString());
20
- });
18
+ basic.forever(function() {
19
+ basic.showString(serial.readString())
20
+ })
21
21
  ```
22
22
 
23
23
  ## See also
@@ -3,7 +3,7 @@
3
3
  Read a text from the serial port until a delimiter is found.
4
4
 
5
5
  ```sig
6
- serial.readUntil(",");
6
+ serial.readUntil(",")
7
7
  ```
8
8
 
9
9
  ## Returns
@@ -16,9 +16,9 @@ The following example reads strings separated by commands (``,``).
16
16
 
17
17
  ```blocks
18
18
  basic.forever(() => {
19
- let answer = serial.readUntil(",");
20
- serial.writeLine(answer);
21
- });
19
+ let answer = serial.readUntil(",")
20
+ serial.writeLine(answer)
21
+ })
22
22
  ```
23
23
 
24
24
  ## See also
@@ -3,7 +3,7 @@
3
3
  Configure the serial port to use the pins instead of USB.
4
4
 
5
5
  ```sig
6
- serial.redirect(SerialPin.P0, SerialPin.P0, BaudRate.BaudRate115200);
6
+ serial.redirect(SerialPin.P0, SerialPin.P0, BaudRate.BaudRate115200)
7
7
  ```
8
8
  The default connection for the serial port is over a USB cable. You can have the serial data go across wires connected to pins on the @boardname@ instead. To set the input and output for the serial connection to be on the pins, you redirect it to the pins. Also, you decide how fast you want to send and receive the data on the pins by choosing a _baud_ rate.
9
9
 
@@ -14,8 +14,9 @@ The default connection for the serial port is over a USB cable. You can have the
14
14
  * **rate**: the baud rate for transmitting and receiving data. Baud rates you can choose from are:
15
15
  >`300`, `1200`, `2400`, `4800`, `9600`, `14400`, `19200,`, `28800`, `31250`, `38400`, `57600`, or `115200`
16
16
 
17
- ## ~hint
18
- **Baud rate**
17
+ ### ~hint
18
+
19
+ #### Baud rate
19
20
 
20
21
  Serial communication transmits data by sending one bit of a [digital number](/types/buffer/number-format) (usually a byte sized number), at a time. So, the data bytes are sent as a series of their bits. Serial communication uses just one wire to send these bits so only one bit can travel across the wire at a time.
21
22
 
@@ -23,7 +24,7 @@ When pins on your @boardname@ are configured for serial communication, they make
23
24
 
24
25
  You will typically use `9600` or `115200` for your baud rate. Sometimes the device you connect to can figure out what your baud rate is. Most of the time though, you need to make sure the device you connect to is set to match your baud rate.
25
26
 
26
- ## ~
27
+ ### ~
27
28
 
28
29
  ## Example
29
30
 
@@ -32,9 +33,9 @@ serial port to use the pins. The new configuration uses pin ``P1`` to transmit a
32
33
  ``P2`` to receive. The baud rate is set to `9600`.
33
34
 
34
35
  ```blocks
35
- input.onButtonPressed(Button.A, () => {
36
- serial.redirect(SerialPin.P1, SerialPin.P2, BaudRate.BaudRate9600);
37
- });
36
+ input.onButtonPressed(Button.A, function() {
37
+ serial.redirect(SerialPin.P1, SerialPin.P2, BaudRate.BaudRate9600)
38
+ })
38
39
  ```
39
40
 
40
41
  ## See also
@@ -0,0 +1,56 @@
1
+ # set Baud Rate
2
+
3
+ Set the baud rate of the serial connection.
4
+
5
+ ```sig
6
+ serial.setBaudRate(BaudRate.BaudRate115200)
7
+ ```
8
+
9
+ The baud rate of the serial connection is the speed at which it will transmit data. You can set one of several standard rates for the transmit speed. The receiving @boardname@ or device must be set to receive data at the same speed as the sending @boardname@.
10
+
11
+ ### ~ hint
12
+
13
+ #### Bits and bauds
14
+
15
+ Baud, or _baud rate_, is a very old measure of data speed. It originates from the early days of _teletype_ when characters of the alphabet were transmitted over telegraph wires. Signal changes on the wires are used to encode a sequence of bits that represented a character in a message. The baud rate is how many times per second these signal changes happen. When binary data (digital bits) is transmitted over an analog system, like telegraph or telephone wires, the bits are _modulated_ by
16
+ a signal changing scheme to represent them. Sometimes mutliple bits are transmitted in a signal
17
+ change which makes the actual _bit rate_ faster than the baud rate.
18
+
19
+ ### ~
20
+
21
+ ## Parameters
22
+
23
+ * **rate**: The baud rate to set for the serial connection. The default rate is `115200` baud, The rates to choose from are:
24
+ >* `1200` baud
25
+ >* `2400` baud
26
+ >* `4800` baud
27
+ >* `9600` baud
28
+ >* `14400` baud
29
+ >* `19200` baud
30
+ >* `28800` baud
31
+ >* `31250` baud
32
+ >* `38400` baud
33
+ >* `57600` baud
34
+ >* `115200` baud
35
+
36
+ ### ~reminder
37
+
38
+ #### Logging serial data
39
+
40
+ In order for the serial console log to record your serial data, the baud rate MUST remain
41
+ at `115200` (the default).
42
+
43
+ ### ~
44
+
45
+ ## Example
46
+
47
+ Set the baud rate to `9600` and send a message over USB serial to a computer.
48
+
49
+ ```blocks
50
+ serial.setBaudRate(BaudRate.BaudRate9600)
51
+ serial.writeString("This is my SERIAL message!")
52
+ ```
53
+
54
+ ## See also
55
+
56
+ [redirect](/reference/serial/redirect)
@@ -0,0 +1,51 @@
1
+ # set Write Line Padding
2
+
3
+ Sets the padding length for text lines written to the serial port.
4
+
5
+ ```sig
6
+ serial.setWriteLinePadding(0)
7
+ ```
8
+
9
+ When text is written to the serial port as a "line", it can have an amount of padding to keep the line at a certian length. If the write line padding is set to `32` and the length of text sent with [write line](/reference/serial/write-line) is only `15` characters, then additional `space` characters are added to make the line length `32` characters.
10
+
11
+ Also, the padding length will account for the NEWLINE characters that terminate the line.
12
+
13
+ ### ~ hint
14
+
15
+ #### Serial input buffers
16
+
17
+ Some devices that you connect a @boardname@ to with the serial port might collect the text you send to them in a buffer before they transfer it to a program that will process it. You can ensure that the connected device will respond to your messege by using padding to make the text you sent transfer out of the connected device's input buffer right away. If you know that the device connected to your @boardname@ will release the text in its input buffer when `64` characters are collected, you can set the write line padding length to `64` before you send your message.
18
+
19
+ ### ~
20
+
21
+ In this example, the a line of text `"Hello Serial!"` is written to the serial port.
22
+
23
+ ```block
24
+ serial.setWriteLinePadding(24)
25
+ serial.writeLine("Hello Serial!")
26
+ ```
27
+
28
+ In this case, the output will NOT be:
29
+
30
+ `Hello Serial!\r\n`
31
+
32
+ Instead, it will include addtional space characters to make the line length `24` characters:
33
+
34
+ `Hello Serial! \r\n`
35
+
36
+ ## Parameters
37
+
38
+ * **length**: a [number](/types/number) between `0` and `128` that sets the padding length for lines of text written to the serial port. The default padding length is `32`.
39
+
40
+ ## Example
41
+
42
+ Set the write line padding to `48` characters and write a message line to the serial port.
43
+
44
+ ```block
45
+ serial.setWriteLinePadding(48)
46
+ serial.writeString("This is my SERIAL message!")
47
+ ```
48
+
49
+ ## See also
50
+
51
+ [write line](/reference/serial/write-line)
@@ -3,7 +3,7 @@
3
3
  Write a buffer to the [serial](/device/serial) port.
4
4
 
5
5
  ```sig
6
- serial.writeBuffer(pins.createBuffer(0));
6
+ serial.writeBuffer(pins.createBuffer(0))
7
7
  ```
8
8
 
9
9
  You place your data characters into an existing buffer. All of the data, the length of the buffer, is written to the serial port.
@@ -17,9 +17,9 @@ You place your data characters into an existing buffer. All of the data, the len
17
17
  Read some characters of data from a device connected to the I2C pins. Write the data to the serial port.
18
18
 
19
19
  ```typescript
20
- pins.i2cWriteNumber(132, NumberFormat.UInt8LE, 0);
21
- let i2cBuffer = pins.i2cReadBuffer(132, 16, false);
22
- serial.writeBuffer(i2cBuffer);
20
+ pins.i2cWriteNumber(132, NumberFormat.UInt8LE, 0)
21
+ let i2cBuffer = pins.i2cReadBuffer(132, 16, false)
22
+ serial.writeBuffer(i2cBuffer)
23
23
  ```
24
24
 
25
25
  ## See also
@@ -4,7 +4,7 @@ Write a string to the [serial](/device/serial) port and start a new line of text
4
4
  by writing `\r\n`.
5
5
 
6
6
  ```sig
7
- serial.writeLine("");
7
+ serial.writeLine("")
8
8
  ```
9
9
 
10
10
  ## Parameters
@@ -18,10 +18,10 @@ serial.writeLine("");
18
18
  Write the word `BOFFO` to the serial port repeatedly.
19
19
 
20
20
  ```blocks
21
- basic.forever(() => {
22
- serial.writeLine("BOFFO");
23
- basic.pause(5000);
24
- });
21
+ basic.forever(function() {
22
+ serial.writeLine("BOFFO")
23
+ basic.pause(5000)
24
+ })
25
25
  ```
26
26
 
27
27
  ### Streaming data
@@ -31,7 +31,7 @@ Check the [compass heading](/reference/input/compass-heading) and show the direc
31
31
  ```blocks
32
32
  let degrees = 0
33
33
  let direction = ""
34
- basic.forever(() => {
34
+ basic.forever(function() {
35
35
  degrees = input.compassHeading()
36
36
  if (degrees < 45) {
37
37
  basic.showArrow(ArrowNames.North)
@@ -3,7 +3,7 @@
3
3
  Write a number to the [serial](/device/serial) port.
4
4
 
5
5
  ```sig
6
- serial.writeNumber(0);
6
+ serial.writeNumber(0)
7
7
  ```
8
8
 
9
9
  ## Parameters
@@ -15,9 +15,9 @@ serial.writeNumber(0);
15
15
  This program repeatedly writes a 3-digit number to the serial port.
16
16
 
17
17
  ```blocks
18
- basic.forever(() => {
19
- serial.writeNumber(123);
20
- basic.pause(5000);
18
+ basic.forever(function() {
19
+ serial.writeNumber(123)
20
+ basic.pause(5000)
21
21
  });
22
22
  ```
23
23
 
@@ -27,9 +27,9 @@ If you use the ``led.plotBarGraph`` function, it writes the number
27
27
  being plotted to the serial port too.
28
28
 
29
29
  ```blocks
30
- basic.forever(() => {
30
+ basic.forever(function() {
31
31
  led.plotBarGraph(input.lightLevel(), 255)
32
- basic.pause(10000);
32
+ basic.pause(10000)
33
33
  })
34
34
  ```
35
35
 
@@ -3,7 +3,7 @@
3
3
  Write an array of numbers to the [serial](/device/serial) port.
4
4
 
5
5
  ```sig
6
- serial.writeNumbers([0, 1, 2]);
6
+ serial.writeNumbers([0, 1, 2])
7
7
  ```
8
8
 
9
9
  Instead of writing a single number at a time using [write number](/reference/serial/write-number), you can write multiple numbers to the serial port at once. They are written as _Comma Separated Values (CSV)_.
@@ -23,17 +23,17 @@ This makes a line of CSV data where the commas between the numbers are the separ
23
23
  This program repeatedly writes a 3-number array to the serial port.
24
24
 
25
25
  ```blocks
26
- basic.forever(() => {
27
- serial.writeNumbers([1, 2, 3]);
28
- basic.pause(5000);
29
- });
26
+ basic.forever(function() {
27
+ serial.writeNumbers([1, 2, 3])
28
+ basic.pause(5000)
29
+ })
30
30
  ```
31
31
 
32
32
  ## Example: plot temperature and light
33
33
 
34
34
  ```blocks
35
35
  serial.writeLine("temp,light")
36
- basic.forever(() => {
36
+ basic.forever(function() {
37
37
  serial.writeNumbers([input.temperature(), input.lightLevel()])
38
38
  })
39
39
  ```