0:00:00.640,0:00:02.159 to make my door alarm I've got a new 0:00:02.159,0:00:04.000 make code project let's get rid of the 0:00:04.000,0:00:05.759 on start block but we're going to keep 0:00:05.759,0:00:07.120 the forever block because we're going to 0:00:07.120,0:00:09.080 keep checking the magnetic field 0:00:09.080,0:00:11.639 measured by the microbits magnetometer 0:00:11.639,0:00:12.839 its 0:00:12.839,0:00:16.199 Compass go to logic and find the if 0:00:16.199,0:00:19.199 block and drag that in and also in logic 0:00:19.199,0:00:21.199 you'll find the comparison block so get 0:00:21.199,0:00:23.240 that hexagonal block and drop it on top 0:00:23.240,0:00:24.519 of 0:00:24.519,0:00:27.800 true then if we go to input and click on 0:00:27.800,0:00:29.960 more you'll find a block called magnet 0:00:29.960,0:00:33.640 magnetic force drop it in the first Hole 0:00:33.640,0:00:36.320 In the comparison block and we're going 0:00:36.320,0:00:39.320 to change it so it measures the overall 0:00:39.320,0:00:41.440 strength of the magnetic force your 0:00:41.440,0:00:43.120 microbits magnetometer can measure 0:00:43.120,0:00:44.920 magnetic force in different dimensions 0:00:44.920,0:00:47.199 but we're just interested in just how 0:00:47.199,0:00:49.399 strong it is overall and we're going to 0:00:49.399,0:00:50.960 pop a number in here that we might need 0:00:50.960,0:00:52.480 to change later but I'm just going to 0:00:52.480,0:00:55.120 pick 200 for the moment it measures the 0:00:55.120,0:00:56.760 strength of magnetic field in a unit 0:00:56.760,0:00:59.480 called micro Teslas and I'm going to try 0:00:59.480,0:01:01.519 200 to to start with if the magnetic 0:01:01.519,0:01:05.360 field Falls below 200 micro Teslas I'm 0:01:05.360,0:01:08.400 going to show an angry face because what 0:01:08.400,0:01:10.200 that will mean is the magnet has gone 0:01:10.200,0:01:12.040 away from my microbit somebody's opened 0:01:12.040,0:01:14.680 the door and uh we want to know 0:01:14.680,0:01:15.880 someone's been in the room so it's going 0:01:15.880,0:01:18.119 to show an angry face on the 0:01:18.119,0:01:20.799 display how do I know what number to 0:01:20.799,0:01:22.520 pick for the magnetic force how do I 0:01:22.520,0:01:24.280 know how strong my magnet is well we're 0:01:24.280,0:01:26.320 going to do something to sort that out 0:01:26.320,0:01:29.360 so if we go to input drag in on button a 0:01:29.360,0:01:30.840 press 0:01:30.840,0:01:33.600 and we'll add a show number block and 0:01:33.600,0:01:36.040 let's copy the magnetic force block if I 0:01:36.040,0:01:38.759 right click on it duplicate and drag it 0:01:38.759,0:01:40.680 in here and drop it there what this 0:01:40.680,0:01:43.479 means now is that when I press button a 0:01:43.479,0:01:45.520 I can measure the amount of magnetic 0:01:45.520,0:01:47.759 force measured by my microbit I can see 0:01:47.759,0:01:48.799 it on the 0:01:48.799,0:01:51.920 display so we're ready to try this out 0:01:51.920,0:01:53.719 now doesn't work in the simulator so 0:01:53.719,0:01:54.640 we're going to need to put this on a 0:01:54.640,0:01:57.079 real microbit so uh I'm going to call it 0:01:57.079,0:01:59.880 door alarm and I'm going to download the 0:01:59.880,0:02:03.759 hex file and transfer it to my microbit 0:02:03.759,0:02:05.680 I fix the microbit in the battery pack 0:02:05.680,0:02:07.320 to the door frame using something like 0:02:07.320,0:02:09.720 blue Tack and put the magnet on the door 0:02:09.720,0:02:11.800 itself very close to it have a look on 0:02:11.800,0:02:13.640 the back of your microbit board and see 0:02:13.640,0:02:15.400 where the compass is you need to make 0:02:15.400,0:02:17.599 sure the magnet is close to the compass 0:02:17.599,0:02:19.599 chip on the back of your 0:02:19.599,0:02:22.400 microbit now we can calibrate it with 0:02:22.400,0:02:26.000 the door closed press button a and get a 0:02:26.000,0:02:28.239 reading of the magnetic field strength 0:02:28.239,0:02:30.319 in my case it's around 0:02:30.319,0:02:32.599 453 microteslas 0:02:32.599,0:02:35.319 I'm then going to open the door and 0:02:35.319,0:02:37.640 press button a again and take a reading 0:02:37.640,0:02:41.400 with the door open it's 129 micro Teslas 0:02:41.400,0:02:43.080 now it can still measure some magnetism 0:02:43.080,0:02:45.000 don't forget the Earth is magnetic and 0:02:45.000,0:02:46.360 there are other things probably in my 0:02:46.360,0:02:47.959 house that are magnetic as well so the 0:02:47.959,0:02:49.680 microb bit is still picking up some 0:02:49.680,0:02:52.879 magnetic field so my number of 200 0:02:52.879,0:02:55.720 should work pretty well if it's more 0:02:55.720,0:02:58.360 than 200 it means the door is shut which 0:02:58.360,0:03:00.239 sounds likely cuz with the door shut I 0:03:00.239,0:03:03.640 had 453 micro Teslas if it's below 200 0:03:03.640,0:03:04.959 that probably means someone's open the 0:03:04.959,0:03:06.680 door in this case I know that when my 0:03:06.680,0:03:09.920 door is open I have 129 micro Teslas so 0:03:09.920,0:03:11.680 that should work okay now I should be 0:03:11.680,0:03:13.840 able to tell when someone open my door 0:03:13.840,0:03:17.040 an angry face will appear on my microbit 0:03:17.040,0:03:18.640 display and I'll know that somebody has 0:03:18.640,0:03:20.760 been in my room there are lots of things 0:03:20.760,0:03:22.360 you could do to this project to augment 0:03:22.360,0:03:24.080 it you could perhaps add a delay to give 0:03:24.080,0:03:26.280 yourself some time to get out the room 0:03:26.280,0:03:28.159 remember if you need to reset it you can 0:03:28.159,0:03:30.239 just press button a to show the magnetic 0:03:30.239,0:03:31.599 force again and that will clear the 0:03:31.599,0:03:33.920 angry face off the display on your 0:03:33.920,0:03:36.080 microbit uh maybe you could add an 0:03:36.080,0:03:38.400 audible alarm as well you could add a 0:03:38.400,0:03:41.480 music block so that when somebody opens 0:03:41.480,0:03:44.360 your door it makes an audible sound to 0:03:44.360,0:03:46.360 warn you that somebody has been inside 0:03:46.360,0:03:48.200 your room there are all sorts of ways 0:03:48.200,0:03:50.920 you could modify this 0:03:50.920,0:03:53.920 project