@ -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`.
|
||||
|
||||
@ -266,4 +266,4 @@ Right now, it's showing 24 hour format: hours go from `0` to `23` and back to `0
|
||||
|
||||
To set it to the current time, you use the **A** and **B** buttons. The **A** button moves the current hour up by one each time it's pressed. The **B** button moves the minutes up by one every time it's pressed.
|
||||
|
||||
Now that you can tell time on your @boardname@ who knows what you will accomplish next. Only, time will tell!
|
||||
Now that you can tell time on your @boardname@ who knows what you will accomplish next. Only, time will tell!
|
||||
|
@ -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.
|
||||
|
||||
@ -107,4 +107,4 @@ input.onGesture(Gesture.Shake, () => {
|
||||
|
||||
Nice! You've got your timer coded now. Go press the ``|Download|`` button and put your code on the @boardname@. When you shake it, it counts down from the time you have set.
|
||||
|
||||
At first, there are zero seconds set. To add ten seconds to the count, press the **A** button. To increase the count by one second, press the **B** button.
|
||||
At first, there are zero seconds set. To add ten seconds to the count, press the **A** button. To increase the count by one second, press the **B** button.
|
||||
|
Reference in New Issue
Block a user