Temperaturmåler

Servo test

Først skal vi lage en kode kun for å teste servo-motoren. Lag et nytt prosjekt og kall dette "servo-test".

Nå skal vi legge inn en forsinkelse slik at servoen roterer, og så venter litt før den roterer igjen til vinkelen vi velger.
 


Koble til servo



Koblingsdiagrammet ligger til venstre. Veldig enkelt som dere ser.


Temperaturmåler

Nå er det tid for å lage koden og koble den til servoen slik som på bildet til venstre.

Steg 1

"Ved start"-blokken har vi ikke bruk for, denne kan du slette.

Steg 2


Step 3

Now, go to the Logic block and choose IF THEN and 0<0 block, replace true with 0<0 block, and place it after "set temperature to" block as above.What we need to do now is to replace the first 0 of 0<0 with temperature variable. Rightclick and copy to make another and place underneath as above. Change the second < to >

We're going to set room temperature to something like 20 degrees. 

So according to code to the left, if the temperature is less than 20, then we're assigning/setting the temperature variable to 20. If not and the temperature is more than 35 degrees, then we're setting the temperature to 35. You can choose any number you want based on the temperature at your place. 

Step 4

Go to pins and then choose map block and servo write block.

Replace 180 in servo write pin to map block. And then set values, meaning we need to map the temperature because according to temperature value only we need to rotate or adjust the servo. So copy temperature block and attach it to map block. 0 should be replaced by temperature. And we need to set low value and high value. So the low value is 20 (see if then else block) and the high value is 35 (see if then else block). So set from low=20 and from high=35. Above first two values are for setting the value and the next two values are used to give the angle to the servo. So set it to 0 and 180 like the above picture to the left.

 So in this case, if the temperature is less than 20 then the servo will be down, meaning at 0 degrees, and if the temperature is more than 35 then it will move to 180 degrees.

That's all, now the code looks like the below picture to the left. Now just download and copy to the MICROBIT DRIVE. And try to heat the CPU and you will see the servo adjusting according to temperature. 


Montering

Tegn en halvsirkel på en skive papp og lag et hull på midten av nederste linje.

Dra av "viseren" og monter med tannhjul gjennom hullet slik at motor og viser er på hver sin side av pappen. Sett på viseren igjen, plassert slik at viseren peker i retning av hva som på bildet til venstre vil være nedover. Deretter er det bare å sette tall på halvsirkelen. Merk at retningen går fra varm til kald.

Under ser du illustrasjon av monteringen