Difference between revisions of "Microbit2"
Line 32: | Line 32: | ||
[[File:mb32.png]] | [[File:mb32.png]] | ||
− | We need to puzzle this | + | We need to puzzle this inside each other, the shapes are helping: |
[[File:mb33.png]] | [[File:mb33.png]] |
Revision as of 16:40, 9 April 2020
If Statement
Why is the temperature so complicated?
What is happening?
Temperature is a number. To get something done we need to tell the microcontroller some "program", like:
do something if the temperature gets below 10 degrees.
This "if" is one of the most important programming principles.
If something is true do THIS. if that something is NOT true, do THAT.
In fact the button input is also like an IF statement:
if the button is pushed, then.....
So we need an IF: - from "LOGIC"
Then we need a comparison from LOGIC
Then we need temperature form INPUT
We need to puzzle this inside each other, the shapes are helping:
and we get this - inside the "FOREVER"
Let's take a look at the Javascript:
Comparison (If you want to know)
Also with the Arduino we use an "IF-statement"
The Arduino doesn't know what is connected to it. For temperature this could be an NTC. (Many other ways to measure the temperature.) The NTC produces an "analog" number, when rightly connected. With special code, adapted to this NTC we have to transform this number in what is called degrees Celsius.
This NTC and the code can be found on this WIKI: http://interactionstation.wdka.hro.nl/wiki/Thermistor
We can see the code:
And we discover the IF statement: