parent
980bb581ee
commit
7e23340df1
@ -14,7 +14,7 @@ Structured courses for teaching science and technology in the classroom.
|
||||
"imageUrl": "/static/courses/csintro.jpg"
|
||||
}, {
|
||||
"name": "Science Experiments",
|
||||
"description": "Science experiment lessons with measurements and data analysis activites",
|
||||
"description": "Science experiment lessons with measurements and data analysis activities",
|
||||
"url":"/courses/ucp-science",
|
||||
"imageUrl": "/static/courses/ucp-science.jpg"
|
||||
}, {
|
||||
|
@ -165,6 +165,6 @@ basic.forever(function () {
|
||||
|
||||
## ~ avatar
|
||||
|
||||
Well done! You've just coded using a "text programming" language! Starting from blocks, you learned to convert them to JavaScript and then modify the code in the blocks as text. Wow, your're a pro now! Go back to [Blocks To JavaScript](/projects/blocks-to-javascript) to continue with another challenge.
|
||||
Well done! You've just coded using a "text programming" language! Starting from blocks, you learned to convert them to JavaScript and then modify the code in the blocks as text. Wow, you're a pro now! Go back to [Blocks To JavaScript](/projects/blocks-to-javascript) to continue with another challenge.
|
||||
|
||||
## ~
|
||||
|
@ -44,7 +44,7 @@ input.onButtonPressed(Button.A, function () {
|
||||
|
||||
Do you want to go back to editing with blocks again? MakeCode can convert your JavaScript code back into blocks.
|
||||
|
||||
* Replace a few dots `.` with hashmarks `#`.
|
||||
* Replace a few dots `.` with hash marks `#`.
|
||||
|
||||
```typescript
|
||||
input.onButtonPressed(Button.A, function () {
|
||||
|
@ -16,7 +16,7 @@ Just like the blocks toolbox, you can drag and drop snippets of JavaScript. It's
|
||||
|
||||
## Suggestions and auto-completion
|
||||
|
||||
When you start typing, you will quickly notice a menu of suggestions poping up right under the cursor. The editor is giving you possible snippets of code based on what you've just written (this is something that professional developer uses every day!).
|
||||
When you start typing, you will quickly notice a menu of suggestions popping up right under the cursor. The editor is giving you possible snippets of code based on what you've just written (this is something that professional developer uses every day!).
|
||||
|
||||
When you see the option for what you were trying to type, press **Enter** to insert it... rather than typing it entirely.
|
||||
|
||||
@ -43,7 +43,7 @@ Check the **indentation lines** to find your way back to the higher code "levels
|
||||
|
||||
When the editor detects a syntax error, it puts red squiggles where it thinks the error is.
|
||||
|
||||
Place your mouse over the squiggle to get a detailled error message to help you fix the problem.
|
||||
Place your mouse over the squiggle to get a detailed error message to help you fix the problem.
|
||||
|
||||
![A squiggle message](/static/courses/blocks-to-javascript/jssquiggles.gif)
|
||||
|
||||
|
@ -96,7 +96,7 @@ You see that we used, or called, the function **showMyName** two times and didn'
|
||||
|
||||
You can see that a function is really useful when you want to reuse some code, especially if it's a lot of code! But wait, functions are even more powerful when you can send them some information to work with!
|
||||
|
||||
The **showMyName** function would really be awesome if it could display anyone's name. So, how can we make it do that? Well, let's use a _parameter_. A parameter is like a variable but it's a special varialble only for the function. It allows your program to send, or _pass_, a value to the function. Just like a variable, the parameter has a [type](/types) for the value passed in it. To use a parmeter with a function, we need to work with its code in the JavaScript editor since using a parameter makes the function too complex to be a block.
|
||||
The **showMyName** function would really be awesome if it could display anyone's name. So, how can we make it do that? Well, let's use a _parameter_. A parameter is like a variable but it's a special variable only for the function. It allows your program to send, or _pass_, a value to the function. Just like a variable, the parameter has a [type](/types) for the value passed in it. To use a parmeter with a function, we need to work with its code in the JavaScript editor since using a parameter makes the function too complex to be a block.
|
||||
|
||||
Go over to the JavaScript editor and change the function's name from **showMyName** to just **showName**. Give it a parameter to display anyone's name by inserting ``name: string`` in between the `(` `)` after the function name.
|
||||
|
||||
|
@ -98,7 +98,7 @@ You can attach an external device such as a motor to these and power it using th
|
||||
|
||||
## Serial Communication
|
||||
|
||||
The micro:bit can send and receive data via [serial communication](/device/serial). The serial data can be transfered via USB or BLE.
|
||||
The micro:bit can send and receive data via [serial communication](/device/serial). The serial data can be transferred via USB or BLE.
|
||||
|
||||
## Bluetooth Low Energy (BLE) Antenna
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Data Analysis
|
||||
|
||||
In addition to learning programming, the @boardname@ is a fantastic tool for observing and measuring things that happen in the natural world. The sciences rely on methods of observation, information gathering, and analysis. Using the @boardname@ with MakeCode, you can use the sensors and inputs to measure and capture physical events that occur. Meausrement data can then be sent for recording by other devices like another @boardname@ or a personal computer.
|
||||
In addition to learning programming, the @boardname@ is a fantastic tool for observing and measuring things that happen in the natural world. The sciences rely on methods of observation, information gathering, and analysis. Using the @boardname@ with MakeCode, you can use the sensors and inputs to measure and capture physical events that occur. Measurement data can then be sent for recording by other devices like another @boardname@ or a personal computer.
|
||||
|
||||
![Data graph logo](/static/mb/device/data-analysis/data-analysis.jpg)
|
||||
|
||||
|
@ -53,7 +53,7 @@ This time both values are shown on the same chart. We used ``||serial:serial wri
|
||||
|
||||
## Raw data
|
||||
|
||||
The data in the console window appears exacly like it's written by your program. The data your program writes is called "raw" data. The Data Viewer reads the data and "cooks" it by deciding how to display it in a way that's useful to you.
|
||||
The data in the console window appears exactly like it's written by your program. The data your program writes is called "raw" data. The Data Viewer reads the data and "cooks" it by deciding how to display it in a way that's useful to you.
|
||||
|
||||
You can select and copy the raw data from the console and paste it into another program if you want to work with it outside of the MakeCode editor. Also, there is a copy button next to the console window that let's you easily copy the raw data with one click.
|
||||
|
||||
@ -93,7 +93,7 @@ time (source1) x time (source1) y
|
||||
|
||||
The first line says what character is used as the value separator. Characters other than a comma can be used as separators. The Data Viewer choose to use a `TAB` character. The next line contains the headings for the values. These are the names of each value when name value pairs are written to the console. Also, a time value (timestamp) is included for each value. The timestamp is the amount of time since the start of the program when the value was written.
|
||||
|
||||
The remaining lines contain the data values and their timestamps. Each line has one occurance of each value. So, for the example data above, each new `x` and `y` value is put together on the same line.
|
||||
The remaining lines contain the data values and their timestamps. Each line has one occurrence of each value. So, for the example data above, each new `x` and `y` value is put together on the same line.
|
||||
|
||||
### Loading into a spreadsheet
|
||||
|
||||
|
@ -28,7 +28,7 @@ basic.forever(() => {
|
||||
|
||||
## Plot range
|
||||
|
||||
A number of LEDs will light up to show how much the value is related to the _high_ number in the second arguement. The high number sets the _range_ of values to show. If the high number is set to `16` and you want to plot the value of `8`, then that value is half of the range.
|
||||
A number of LEDs will light up to show how much the value is related to the _high_ number in the second argument. The high number sets the _range_ of values to show. If the high number is set to `16` and you want to plot the value of `8`, then that value is half of the range.
|
||||
|
||||
```block
|
||||
led.plotBarGraph(8, 16)
|
||||
@ -60,7 +60,7 @@ for (let i = 0; i < values.length; i++) {
|
||||
|
||||
## Recording plotted values
|
||||
|
||||
The ``||led:plot bar graph||`` also sends the number value it's plotting to the console. You can see the output in the Data Viewer. It charts the values and they appear as indivdual numbers in console.
|
||||
The ``||led:plot bar graph||`` also sends the number value it's plotting to the console. You can see the output in the Data Viewer. It charts the values and they appear as individual numbers in console.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.B, () => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Remote data collection
|
||||
|
||||
If you have more than one @boardname@ you can setup one of them to receive data sent by radio from other @boardname@s. Remote @boardname@s can take measurements and send them to a board that's connected by USB to a computer. The @boardname@ connected to the computer is the data recorder and writes the recieved data to the serial port.
|
||||
If you have more than one @boardname@ you can setup one of them to receive data sent by radio from other @boardname@s. Remote @boardname@s can take measurements and send them to a board that's connected by USB to a computer. The @boardname@ connected to the computer is the data recorder and writes the received data to the serial port.
|
||||
|
||||
![Remote micro:bit sending](/static/mb/device/data-analysis/radio-zap.jpg)
|
||||
|
||||
@ -31,7 +31,7 @@ A remote @boardname@ reads its measurement values and sends them to the same rad
|
||||
```block
|
||||
radio.setGroup(99)
|
||||
```
|
||||
A typical measurment progam might read a sensor value continously. Depending on how much the values change, the meaurement program could contain the read operation in a loop with a delay interval. In the example here, the delay is one minute between each read of a temperature value. The value is sent on the current radio group with ``||radio:radio send number||``.
|
||||
A typical measurement program might read a sensor value continuously. Depending on how much the values change, the measurement program could contain the read operation in a loop with a delay interval. In the example here, the delay is one minute between each read of a temperature value. The value is sent on the current radio group with ``||radio:radio send number||``.
|
||||
|
||||
```blocks
|
||||
let temperature = 0
|
||||
|
@ -62,7 +62,7 @@ serial.writeNumber(2)
|
||||
serial.writeNumber(3)
|
||||
```
|
||||
|
||||
The numbers don't show up as single values because they appear in the output as a string: `"123"`. Also, the string doesn't form a complete line so it doesn't show up in the console window either. You could add a blank line to the numbers alreay written. If you did this, you would have just one value charted which is `123`:
|
||||
The numbers don't show up as single values because they appear in the output as a string: `"123"`. Also, the string doesn't form a complete line so it doesn't show up in the console window either. You could add a blank line to the numbers already written. If you did this, you would have just one value charted which is `123`:
|
||||
|
||||
```block
|
||||
serial.writeNumber(1)
|
||||
|
@ -6,7 +6,7 @@ Below is a list of error numbers and what they mean:
|
||||
|
||||
* **10** (`MICROBIT_I2C_LOCKUP`): the @boardname@'s I2C bus is not working
|
||||
* **20** (`MICROBIT_OOM`): there is no free memory on the @boardname@
|
||||
* **30** (`MICORBIT_HEAP_ERROR`): a problem in the heap space.
|
||||
* **30** (`MICROBIT_HEAP_ERROR`): a problem in the heap space.
|
||||
* **40** (`MICROBIT_NULL_DEREFERENCE `): there was a NULL dereference, the @boardname@ tried to manage a invalid object pointer.
|
||||
* **42** (`MICROBIT_SYSTEM_ERROR`): there's an error condition in the @boardname@ system software.
|
||||
* **43** (`MICROBIT_NO_RADIO`): the @boardname@ can't enable the radio.
|
||||
|
@ -3,8 +3,8 @@
|
||||
The large holes at the bottom of the board are designed to attach alligator/crocodile clips
|
||||
to create electrical circuit with other components.
|
||||
|
||||
If you do not have crocodile clips at hand, dyou can use wires or even Aluminium foil to acheive the same result.
|
||||
We will show you how to connect the @boardname@ to headphones using Alumunium foil and tape.
|
||||
If you do not have crocodile clips at hand, you can use wires or even Aluminium foil to achieve the same result.
|
||||
We will show you how to connect the @boardname@ to headphones using Aluminium foil and tape.
|
||||
|
||||
https://youtu.be/mhXYyPuvpz0
|
||||
|
||||
@ -21,7 +21,7 @@ Tape the @boardname@ and battery pack to the card board. Make sure to remove the
|
||||
|
||||
![](/static/mb/device/croc-clips/microbitattached.jpg)
|
||||
|
||||
Cut the thinest strip of foil possible and roll it into a cable. You can also try to fold, whatever works for you.
|
||||
Cut the thinnest strip of foil possible and roll it into a cable. You can also try to fold, whatever works for you.
|
||||
Build two of those wires.
|
||||
|
||||
![](/static/mb/device/croc-clips/foilcut.jpg)
|
||||
|
@ -116,7 +116,7 @@ Information about the current status of the device
|
||||
* `MES_DEVICE_INCOMING_CALL`: Currently receiving an incoming call
|
||||
* `MES_DEVICE_INCOMING_MESSAGE`: A message was received (SMS or other messaging app)
|
||||
|
||||
### Game pad contoller
|
||||
### Game pad controller
|
||||
|
||||
Button events from a paired game pad.
|
||||
|
||||
|
@ -11,11 +11,11 @@ If you are running a class or activity, you should consider preparing all servos
|
||||
The @boardname@ provides just enough current to operate the SG90 microservo.
|
||||
The servo requires 3 connections: GND, 3V and a logic pin.
|
||||
In this tutorial, we will equip the servo with crocodile clips to make it easier to use.
|
||||
However, you could also use a shield or female to crocodile clips to acheive the same effect.
|
||||
However, you could also use a shield or female to crocodile clips to achieve the same effect.
|
||||
|
||||
## The easy way: Alligator/Crocobile Clip to Male Jumpers #hintconnection
|
||||
## The easy way: Alligator/Crocodile Clip to Male Jumpers #hintconnection
|
||||
|
||||
The easiest way to connect a servo to the @boardname@ is to use cables that have an **Alligator/Crocobile clip** on one end
|
||||
The easiest way to connect a servo to the @boardname@ is to use cables that have an **Alligator/Crocodile clip** on one end
|
||||
and a **Male jumper (pig tail)** on the other end. You can purchase bundles of such cables from various electronic resellers or easily build yours as show below.
|
||||
|
||||
https://youtu.be/XtzsydSTXEg
|
||||
@ -66,7 +66,7 @@ Thread the servo cables.
|
||||
|
||||
![](/static/mb/projects/inchworm/servo3.jpg)
|
||||
|
||||
## Step 4: crocobile clip
|
||||
## Step 4: crocodile clip
|
||||
|
||||
Cut a crocodile cable in two and strip out the casing.
|
||||
If possible try to use the same cable colors as the servo!
|
||||
|
@ -211,7 +211,7 @@ Check out [microbit.org](http://microbit.org/resellers/) for more information on
|
||||
"url":"/pkg/mbitfun/pxt-katakana",
|
||||
"cardType": "package"
|
||||
}, {
|
||||
"name": "Muselab WiFi IoT Sheild",
|
||||
"name": "Muselab WiFi IoT Shield",
|
||||
"url":"/pkg/MUSELAB/pxt-wifi-shield",
|
||||
"cardType": "package"
|
||||
}, {
|
||||
|
@ -46,7 +46,7 @@ let obstacles: game.LedSprite[] = []
|
||||
Now generate vertical obstacles consisting of 4 sprites and 1 random hole.
|
||||
Create new variable called `emptyObstacleY`. Using ``||math:pick random||``, generate a random number from `0` to `4` and store it inside `emptyObstacleY`.
|
||||
|
||||
Using ``||loops:for||`` loop, iterate from `0` to `4`. For every coordinate not equal to `emptyObstacleY` create and add obstacle sprites to the endo fo the `obstacles` array.
|
||||
Using ``||loops:for||`` loop, iterate from `0` to `4`. For every coordinate not equal to `emptyObstacleY` create and add obstacle sprites to the end of the `obstacles` array.
|
||||
|
||||
```blocks
|
||||
let emptyObstacleY = 0
|
||||
|
@ -59,7 +59,7 @@ basic.forever(() => {
|
||||
```
|
||||
**Create the code** that measures the change in the Y axis acceleration as a graph on the LEDs
|
||||
|
||||
**Dowload the code** to the @boardname@
|
||||
**Download the code** to the @boardname@
|
||||
|
||||
**Test the movements that move the graph from 1 to 5 bars on the LEDs**
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
## ~avatar avatar
|
||||
|
||||
Did you know you could attach your headhpones to the @boardname@ to generate sounds?
|
||||
Did you know you could attach your headphones to the @boardname@ to generate sounds?
|
||||
|
||||
## ~
|
||||
|
||||
|
@ -81,7 +81,7 @@ The hunter's screen will display:
|
||||
|
||||
Use the ``signal`` values collected in the previous step to determine when to show each icon.
|
||||
|
||||
Here is an example that uses ``-95`` or less for cold, between ``-95`` and ``-80`` for warm, and ``-80`` or above for hot. You can change these values to account for your room setup or conditions of your hidding place.
|
||||
Here is an example that uses ``-95`` or less for cold, between ``-95`` and ``-80`` for warm, and ``-80`` or above for hot. You can change these values to account for your room setup or conditions of your hiding place.
|
||||
|
||||
To make the program more responsive, add a ``||led:stop animation||`` to cancel icon animations when a new beacon packet comes in.
|
||||
|
||||
|
@ -17,7 +17,7 @@ https://youtu.be/BiZLjugXMbM
|
||||
## Materials
|
||||
|
||||
* 3 Coffee cup holders (hot cup sleeves)
|
||||
* 2 Wood coffee strirer sticks
|
||||
* 2 Wood coffee stirrer sticks
|
||||
* Glue gun
|
||||
* Scissors that can cut cardboard
|
||||
* 1 @boardname@, battery holder and 2 AAA batteries
|
||||
|
@ -13,7 +13,7 @@ Turn some coffee cup holders into a monster that moves to light!
|
||||
## Materials
|
||||
|
||||
* 3 coffee cup holders (hot cup sleeves)
|
||||
* 2 ood coffee strirer sticks
|
||||
* 2 wood coffee stirrer sticks
|
||||
* scissors
|
||||
* glue gun or tape
|
||||
* 1 paper clip
|
||||
|
@ -19,7 +19,7 @@ Happy mining!
|
||||
|
||||
## Coins, blocks, chains
|
||||
|
||||
A _block chain_ is a list of _blocks_ that record transactions of a crypto-currency like BitCoin. A block might contain information like the time it was created (mined) and who mined it. The most important part of the block is it's _hash_. This is a special number made from the information in the last block of the block list combined with the hash number of previous block in the list. The new block contains information for the current transaction and this new hash number. The new block is added to the list of previous blocks. This list is then transmitted to the crypto currency network. It's really hard (like impossible) to tamper or forge a hash which allows the block chain to be transmitted publically.
|
||||
A _block chain_ is a list of _blocks_ that record transactions of a crypto-currency like BitCoin. A block might contain information like the time it was created (mined) and who mined it. The most important part of the block is it's _hash_. This is a special number made from the information in the last block of the block list combined with the hash number of previous block in the list. The new block contains information for the current transaction and this new hash number. The new block is added to the list of previous blocks. This list is then transmitted to the crypto currency network. It's really hard (like impossible) to tamper or forge a hash which allows the block chain to be transmitted publicly.
|
||||
|
||||
## ~ hint
|
||||
|
||||
|
@ -20,7 +20,7 @@ https://youtu.be/Ah4fEbJtklU
|
||||
## Recycled
|
||||
|
||||
* 1 Milk Carton **without a screwable cap**
|
||||
* 2 Coffee stiring wood sticks
|
||||
* 2 Coffee stirring wood sticks
|
||||
* 2 Straws
|
||||
* 2 clothespin (optional, can be replaced by glue)
|
||||
|
||||
|
@ -9,7 +9,7 @@ Remote control your Milk Carton Robot with another @boardname@
|
||||
## Duration: ~30 minutes
|
||||
|
||||
You will need 2 @boardname@ for this part. By using the radio, we can make the Milk Carton Monster controlled by another @boardname@.
|
||||
Download the code below to the @boardname@ on the Milk Carton Monster and another "controller" @boardname@. Whenere ``A`` is pressed, the Milk Carton Monster will move once.
|
||||
Download the code below to the @boardname@ on the Milk Carton Monster and another "controller" @boardname@. Whenever ``A`` is pressed, the Milk Carton Monster will move once.
|
||||
|
||||
```blocks
|
||||
radio.onReceivedNumber(({ receivedNumber }) => {
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
![Multiple @boardname@ throwing a dice](/static/mb/projects/multi-dice.png)
|
||||
|
||||
Build a multi-player dice game using the **radio**. The **radio** blocks let you send wireless messages between a @boardnam@ and another @boardname@.
|
||||
Build a multi-player dice game using the **radio**. The **radio** blocks let you send wireless messages between a @boardname@ and another @boardname@.
|
||||
|
||||
In this game, you shake to "throw the dice" and send the result to the other @boardname@. If you receive a result of a dice throw equal or greater than yours, you lose.
|
||||
|
||||
|
@ -139,7 +139,7 @@ start = 0
|
||||
|
||||
## Step 6: Plot LED on X, Y coordinates randomly
|
||||
|
||||
The reaction time will begin if no false start is detected (pin **P0** pressed at the wrong time). When the reaction time starts, a LED is randomly plotted at some the x and y coordinate on the display. Add in the blocks contatined in the ``||logic:if then||`` that show the reaction time:
|
||||
The reaction time will begin if no false start is detected (pin **P0** pressed at the wrong time). When the reaction time starts, a LED is randomly plotted at some the x and y coordinate on the display. Add in the blocks contained in the ``||logic:if then||`` that show the reaction time:
|
||||
|
||||
```blocks
|
||||
let start = 0
|
||||
|
@ -206,7 +206,7 @@ Make sure to rename this program to ``player`` or something like that so you don
|
||||
|
||||
### Tuning
|
||||
|
||||
Does the movement check work? Try changing the ``100`` value to tune the detection sensivity. Try ``64`` maybe.
|
||||
Does the movement check work? Try changing the ``100`` value to tune the detection sensitivity. Try ``64`` maybe.
|
||||
|
||||
### Improve the game
|
||||
|
||||
|
@ -11,7 +11,7 @@ https://youtu.be/8ztOmdZi5Pw
|
||||
Playing rock paper scissors is usually a two player game... but it will work with many more players too!
|
||||
When playing with more than two players, it becomes a team game: all players shake at the same time,
|
||||
then the amount of **rocks**, **paper**, and **scissors** is tallied between all the players.
|
||||
Teams are formed automatcally based on which tool is chosen by shaking the @boardname@. The team with the most players after the shake wins the game.
|
||||
Teams are formed automatically based on which tool is chosen by shaking the @boardname@. The team with the most players after the shake wins the game.
|
||||
|
||||
Starting with the [basic version of the RPS game](/projects/rock-paper-scissors), we are going
|
||||
to change the code so that the @boardname@ counts and displays the number of players on a team.
|
||||
@ -151,7 +151,7 @@ radio.onReceivedNumber(function (receivedNumber) {
|
||||
})
|
||||
```
|
||||
|
||||
## Step 6: Reseting the team
|
||||
## Step 6: Resetting the team
|
||||
|
||||
What if some of the other players leave the game? They would stop broadcasting their status but would still stay in our list of players. To avoid this problem, we reset the ``players`` array each time we shake:
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Salute!
|
||||
|
||||
**Salute!** is a simple math game where players select a number card from a deck (without looking at it) and hold it to their forehead as in a "salute". Another player decides whether to make a sum or product of the two cards and then annouces the result. Based on the card held by the opposing player and the result announced, each player tries to figure out what card they are holding.
|
||||
**Salute!** is a simple math game where players select a number card from a deck (without looking at it) and hold it to their forehead as in a "salute". Another player decides whether to make a sum or product of the two cards and then announces the result. Based on the card held by the opposing player and the result announced, each player tries to figure out what card they are holding.
|
||||
|
||||
## Goals for this activity
|
||||
|
||||
|
@ -61,7 +61,7 @@ We want our soil probes to work for a long time and to save our battery power, s
|
||||
|
||||
* Our circuit connects directly to the **3V** pin so it is always using electricity. Instead,
|
||||
we will connect it to **P1** and turn that pin **high** only while the measurement is taken.
|
||||
This saves electricty and also avoids corrosion of the probes.
|
||||
This saves electricity and also avoids corrosion of the probes.
|
||||
* We will also lower the brightness of the screen to lower the energy consumption from the LEDs.
|
||||
* Soil moisture changes very slowly so we don't need to measure it all the time!!! Let's add a **sleep** of 5 seconds in the loop as well.
|
||||
|
||||
|
@ -24,7 +24,7 @@ led.plot(2, 2)
|
||||
## Step 3
|
||||
|
||||
Now that we know how to send the signal, we only want to do it while the button **A** is pressed.
|
||||
Pick an ``||logic:if then else||`` block from the **Logic** drawer (you'll leave the ``||logic:else||`` part empty for now). Add a check for when button **A** is pressed. Get an ``||inpu:on button pressed||`` from the **Input** drawer and move the blocks from the previous step into ``||logic:then||`` part of the ``||logic:if then else||``:
|
||||
Pick an ``||logic:if then else||`` block from the **Logic** drawer (you'll leave the ``||logic:else||`` part empty for now). Add a check for when button **A** is pressed. Get an ``||input:on button pressed||`` from the **Input** drawer and move the blocks from the previous step into ``||logic:then||`` part of the ``||logic:if then else||``:
|
||||
|
||||
```blocks
|
||||
if (input.buttonIsPressed(Button.A)) {
|
||||
|
@ -30,7 +30,7 @@ By dividing the distance between the gates by the duration, we get the speed of
|
||||
|
||||
## Materials
|
||||
|
||||
* Carboard
|
||||
* Cardboard
|
||||
* Aluminum foil
|
||||
* Double-side tape (carpet tape)
|
||||
* 4 crocodile clips
|
||||
|
@ -53,7 +53,7 @@ Gently fold the sheet in half.
|
||||
|
||||
![](/static/mb/projects/wallet/hole1.jpg)
|
||||
|
||||
Gently foldy the other way.
|
||||
Gently fold the other way.
|
||||
|
||||
![](/static/mb/projects/wallet/hole2.jpg)
|
||||
|
||||
|
@ -14,7 +14,7 @@ We need to make some variables to keep track of the time and for a few other thi
|
||||
2. Ok, in **Variables** click on `Make a Variable`. Name the variable as `hours`. Drag out a ``||variables:set to||`` block and change the name with the dropdown to `hours`. Place the variable into the ``||basic:on start||`` block.
|
||||
3. Repeat this 4 more times to make variables named `minutes`, `time`, `adjust`, and `ampm`.
|
||||
4. Now, for the ``||variables:set to||`` block for `time`, go to **Text** and drag a `" "` in and replace the `0`.
|
||||
5. For the `ampm` variable, change the `0` there to a `false` from the **Logic** catagory.
|
||||
5. For the `ampm` variable, change the `0` there to a `false` from the **Logic** category.
|
||||
|
||||
```blocks
|
||||
let hours = 0
|
||||
@ -28,7 +28,7 @@ let ampm = false
|
||||
|
||||
So, let's try showing the time on the display. We aren't keeping time yet but we'll just see if we can make our watch show something.
|
||||
|
||||
1. Get in the **Input** catagory and pull out an ``||input:on shake||``. We'll have our watch show the time when it's shaken.
|
||||
1. Get in the **Input** category and pull out an ``||input:on shake||``. We'll have our watch show the time when it's shaken.
|
||||
2. Get another ``||variables:set to||`` and put it into the ``||input:on shake||``. Change the name to `time`.
|
||||
3. Replace the `0` with a ``||text:join||`` from **Text**. Get another ``||text:join||`` and put it into the second slot of the first ``||text:join||`` you pulled out.
|
||||
4. Change the `" "` in the first ``||text:join||`` to the `hours` variable. Change the text in the first slot of the second ``||text:join||`` to `":"`. And, change the last slot in the second ``||text:join||`` to the `minutes` variable.
|
||||
@ -52,8 +52,8 @@ Let's make a way to set the hours for the watch.
|
||||
|
||||
1. In **Input**, find an ``||input:on button pressed||`` an put it somewhere on the workspace.
|
||||
2. Get an ``||logic:if then else||`` block from **Logic** and put it in the ``||input:on button pressed||``.
|
||||
3. From the same **Logic** category, get a ``||logic:0 < 0||`` and relpace the `false` condition with it.
|
||||
4. Change the left `0` in the condtion to the `hours` variable. Change `0` on the right to `23`. This limits our hour count to 23 hours.
|
||||
3. From the same **Logic** category, get a ``||logic:0 < 0||`` and replace the `false` condition with it.
|
||||
4. Change the left `0` in the condition to the `hours` variable. Change `0` on the right to `23`. This limits our hour count to 23 hours.
|
||||
5. In the ``||logic:then||`` section, put a ``||variables:change by||`` there. Select the `hours` variable name from the dropdown.
|
||||
6. In the ``||logic:else||`` section, put a ``||variables:set to||`` there. Select the `hours` variable name from the dropdown and leave the `0`.
|
||||
|
||||
|
@ -28,8 +28,8 @@ We'll use button `A` to add `10` seconds to our time count. The time count of `s
|
||||
|
||||
1. In **Input**, find an ``||input:on button pressed||`` an put it somewhere on the workspace.
|
||||
2. Get an ``||logic:if then||`` block from **Logic** and put it in the ``||input:on button pressed||``.
|
||||
3. From the same **Logic** category, get a ``||logic:0 < 0||`` and relpace the `false` condition with it.
|
||||
4. Change the left `0` in the condtion to the `seconds` variable. Change `0` on the right to `50`. This limits time to just one minute.
|
||||
3. From the same **Logic** category, get a ``||logic:0 < 0||`` and replace the `false` condition with it.
|
||||
4. Change the left `0` in the condition to the `seconds` variable. Change `0` on the right to `50`. This limits time to just one minute.
|
||||
5. In the ``||logic:then||`` section, put a ``||variables:change by||`` there. Select the `seconds` variable name from the dropdown and change the `0` on the right to `10`.
|
||||
6. Add a ``||basic:show number||`` below the ``||variables:change by||``. Change the value to the `seconds` variable. Then, put a ``||basic:clear screen||`` under that.
|
||||
|
||||
@ -50,8 +50,8 @@ Now, we'll use the `B` button to add just `1` second the time count. The time co
|
||||
|
||||
1. In **Input**, find an ``||input:on button pressed||`` an put it somewhere on the workspace.
|
||||
2. Get an ``||logic:if then||`` block from **Logic** and put it in the ``||input:on button pressed||``.
|
||||
3. From the same **Logic** category, get a ``||logic:0 < 0||`` and relpace the `false` condition with it.
|
||||
4. Change the left `0` in the condtion to the `seconds` variable. Change `0` on the right to `60`. Again, this limits the time to just one minute.
|
||||
3. From the same **Logic** category, get a ``||logic:0 < 0||`` and replace the `false` condition with it.
|
||||
4. Change the left `0` in the condition to the `seconds` variable. Change `0` on the right to `60`. Again, this limits the time to just one minute.
|
||||
5. In the ``||logic:then||`` section, put a ``||variables:change by||`` there. Select the `seconds` variable name from the dropdown.
|
||||
6. Add a ``||basic:show number||`` below the ``||variables:change by||``. Change the value to the `seconds` variable. Then, put a ``||basic:clear screen||`` under that.
|
||||
|
||||
|
@ -73,10 +73,10 @@ Full documentation for the @boardname@ Bluetooth profile as used by this applica
|
||||
The @boardname@'s accelerometer (motion detector), magnetometer (digital compass), two buttons on the front, LED Display, IO pins on the edge connector, internal message bus and internal temperature sensor are all exposed as Services so that applications can exploit these features of the device. In addition:
|
||||
|
||||
* the Bluetooth SIG defined Device Information Service is included to allow applications to obtain information such as firmware version details over Bluetooth
|
||||
* there's a Device Firmware Update (DFU) service which allows new @boardname@ code to be flahsed to the device over Bluetooth instead of over USB
|
||||
* there's a Device Firmware Update (DFU) service which allows new @boardname@ code to be flashed to the device over Bluetooth instead of over USB
|
||||
* there's a UART service which allows arbitrary data to be exchanged with the @boardname@ in a way resembling traditional serial communications.
|
||||
|
||||
Everything you can do with the @boardname@ over Bluetooth is achieved through read, write and notify operations. Not all characteristics support all three so check the profile documentation. Often there are Characteristics whose purpose is to allow you to write configuration values which control other behviours. Technically these are called Control Points. For example you can specify the frequency with which accelerometer data is sampled before it is transmitted as a Notification message to your application.
|
||||
Everything you can do with the @boardname@ over Bluetooth is achieved through read, write and notify operations. Not all characteristics support all three so check the profile documentation. Often there are Characteristics whose purpose is to allow you to write configuration values which control other behaviours. Technically these are called Control Points. For example you can specify the frequency with which accelerometer data is sampled before it is transmitted as a Notification message to your application.
|
||||
|
||||
## Want to Know More?
|
||||
|
||||
|
@ -7,7 +7,7 @@ For another device like a smartphone to use any of the Bluetooth "services" whic
|
||||
|
||||
## ~
|
||||
|
||||
The Bluetooth IO pin service makes it possible for another device such as a smartphone to communicate with other electronic 'things' connected to a @boardname@'s edge connector. You could for example, use your smartphone to switch on or off a light which is connected to the @boardname@ or your smartphone could receive data collected from a sensor connected to the @boardname@. In fact you could do both of these things at the same time since the Bluetooth IO pin service lets you interact with multiple 'pins' on the edge conector in different ways all at the same time.
|
||||
The Bluetooth IO pin service makes it possible for another device such as a smartphone to communicate with other electronic 'things' connected to a @boardname@'s edge connector. You could for example, use your smartphone to switch on or off a light which is connected to the @boardname@ or your smartphone could receive data collected from a sensor connected to the @boardname@. In fact you could do both of these things at the same time since the Bluetooth IO pin service lets you interact with multiple 'pins' on the edge connector in different ways all at the same time.
|
||||
|
||||
No additional code is needed on the @boardname@ to use the Bluetooth IO pin service from another device.
|
||||
|
||||
|
@ -37,7 +37,7 @@ Send the value `2055` to the 7-bit I2C address as a 32-bit number. The `32`, big
|
||||
pins.i2cWriteNumber(32, 2055, NumberFormat.Int32BE, false);
|
||||
```
|
||||
|
||||
### Reapeted writes
|
||||
### Repeated writes
|
||||
|
||||
Send three byte values to a device at address `33`.
|
||||
|
||||
|
@ -14,7 +14,7 @@ The data contained in **receivedBuffer** is put there as a data [type](/types).
|
||||
|
||||
## Example: Remote level
|
||||
|
||||
Two @boardname@s work like remote levels. They lie flat and detect any change in the horizontal position of the plane that they sit in. Each board sends its level measurements to the other. Each level measurment is shown on the screen.
|
||||
Two @boardname@s work like remote levels. They lie flat and detect any change in the horizontal position of the plane that they sit in. Each board sends its level measurements to the other. Each level measurement is shown on the screen.
|
||||
|
||||
```typescript
|
||||
let ax = 0;
|
||||
|
@ -10,7 +10,7 @@ It is common when reporting or recording data to use a _Name Value Pair_ (NVP).
|
||||
|
||||
``temperature:-15``
|
||||
|
||||
Associating a name with a value helps to identify related data when different data sources are recorded. For example, if you're reporting both temperature and light intensity, the _name:value_ format helps spreadsheets or other data analysis programs distingush between them and group the same types of values together properly. Reporting two data sources might look like this in the output:
|
||||
Associating a name with a value helps to identify related data when different data sources are recorded. For example, if you're reporting both temperature and light intensity, the _name:value_ format helps spreadsheets or other data analysis programs distinguish between them and group the same types of values together properly. Reporting two data sources might look like this in the output:
|
||||
|
||||
```
|
||||
temperature:-15
|
||||
|
@ -58,7 +58,7 @@ Sometimes you need to have your program tell what type of numbers it will store
|
||||
The formats for numbers stored on the @boardname@ are:
|
||||
|
||||
* `Int8LE`: one byte, signed, little endian
|
||||
* `UInt8LE`: one byte, unsigned, litte endian
|
||||
* `UInt8LE`: one byte, unsigned, little endian
|
||||
* `Int8BE`: one byte, signed, big endian
|
||||
* `UInt8BE`: one byte, unsigned, big endian
|
||||
* `Int16LE`: two bytes, signed, little endian
|
||||
@ -70,7 +70,7 @@ The formats for numbers stored on the @boardname@ are:
|
||||
|
||||
#### ~ hint
|
||||
|
||||
The one byte formats really don't have endianness because there is no ordering needed for just one byte. They are given format types though so that they are consistant with the multi-byte formats. So, there is no difference between `Int8LE` and `Int8BE`, or `UInt8LE` and `UInt8BE`.
|
||||
The one byte formats really don't have endianness because there is no ordering needed for just one byte. They are given format types though so that they are consistent with the multi-byte formats. So, there is no difference between `Int8LE` and `Int8BE`, or `UInt8LE` and `UInt8BE`.
|
||||
|
||||
#### ~
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user