Difference between revisions of "Microbit2"

From Interaction Station Wiki
Jump to navigation Jump to search
(Created page with " == 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 "prog...")
 
(One intermediate revision by the same user not shown)
Line 32: Line 32:
 
[[File:mb32.png]]
 
[[File:mb32.png]]
  
We need to puzzle this indie each other, the shapes are helping:
+
We need to puzzle this inside each other, the shapes are helping:
  
 
[[File:mb33.png]]
 
[[File:mb33.png]]
Line 39: Line 39:
  
 
[[File:mb26.png]]
 
[[File:mb26.png]]
 +
 +
Let's take a look at the Javascript:
 +
 +
[[File:mb34.png]]
 +
 +
 +
----
 +
 +
== 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
 +
 +
[[File:Thermistor01.png]]
 +
 +
We can see the code:
 +
 +
[[File:mb35.png]]
 +
 +
And we discover the IF statement:
 +
 +
[[File:mb36.png]]

Revision as of 17: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"

Mb30.png

Then we need a comparison from LOGIC

Mb31.png

Then we need temperature form INPUT

Mb32.png

We need to puzzle this inside each other, the shapes are helping:

Mb33.png

and we get this - inside the "FOREVER"

Mb26.png

Let's take a look at the Javascript:

Mb34.png



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

Thermistor01.png

We can see the code:

Mb35.png

And we discover the IF statement:

Mb36.png