1 00:00:00,000 --> 00:00:00,500 2 00:00:00,500 --> 00:00:02,660 DOUGLAS KIANG: Hello, my name is Douglas Kiang. 3 00:00:02,660 --> 00:00:06,520 I'm a computer science teacher at Punahou School in Honolulu, Hawaii. 4 00:00:06,520 --> 00:00:10,480 And today, I'm going to be here to talk a little bit about Microsoft's MakeCode 5 00:00:10,480 --> 00:00:17,590 environment that allows us to program these things called micro:bits, 6 00:00:17,590 --> 00:00:23,230 which allow you to embed these in fabrics or cardboard or other kinds 7 00:00:23,230 --> 00:00:24,670 of maker projects. 8 00:00:24,670 --> 00:00:27,610 Really anything tangible you can kind of bring it to life 9 00:00:27,610 --> 00:00:29,620 by working in the MakeCode environment. 10 00:00:29,620 --> 00:00:33,340 So today, I'll show you a bunch of different examples. 11 00:00:33,340 --> 00:00:36,880 This language that Microsoft has created is block based, 12 00:00:36,880 --> 00:00:38,920 but it also goes directly to JavaScript. 13 00:00:38,920 --> 00:00:42,310 And you can also program these things in JavaScript, or even in Python. 14 00:00:42,310 --> 00:00:44,740 And I'll talk a little bit about that as well. 15 00:00:44,740 --> 00:00:49,294 So one of the things about MakeCode is you can use the same language 16 00:00:49,294 --> 00:00:52,210 to program the micro:bits, which is primarily what we're going to talk 17 00:00:52,210 --> 00:00:52,709 about today. 18 00:00:52,709 --> 00:00:55,479 But you can also program Minecraft, which is really 19 00:00:55,479 --> 00:00:56,770 kind of a neat development now. 20 00:00:56,770 --> 00:01:00,190 So you can make things sort of happen in game by writing code. 21 00:01:00,190 --> 00:01:02,560 So it's some neat stuff. 22 00:01:02,560 --> 00:01:04,750 But let's sort of dive right in. 23 00:01:04,750 --> 00:01:10,190 And to support this seminar I've created a bunch of resources online. 24 00:01:10,190 --> 00:01:13,690 And if you go to this tinyurl.com/micro:bitworkshop, 25 00:01:13,690 --> 00:01:19,660 you'll find links to lots of different kinds of projects, things to play with, 26 00:01:19,660 --> 00:01:21,680 places where you can buy these things. 27 00:01:21,680 --> 00:01:24,760 So you can get all of these things there. 28 00:01:24,760 --> 00:01:29,080 Lots more than probably we'll have time to cover here. 29 00:01:29,080 --> 00:01:32,530 But I encourage you to go out and explore and find lots of resources 30 00:01:32,530 --> 00:01:34,220 to learn more about these things. 31 00:01:34,220 --> 00:01:35,980 Now, just some caveats here. 32 00:01:35,980 --> 00:01:38,234 First of all, I don't work for Microsoft. 33 00:01:38,234 --> 00:01:39,400 I don't represent Microsoft. 34 00:01:39,400 --> 00:01:40,610 I'm a high school teacher. 35 00:01:40,610 --> 00:01:42,340 And I use these in my class all the time. 36 00:01:42,340 --> 00:01:42,890 We love them. 37 00:01:42,890 --> 00:01:46,057 We use them as a way to introduce computers and computer science. 38 00:01:46,057 --> 00:01:47,890 And then we also use them to go a little bit 39 00:01:47,890 --> 00:01:51,180 deeper into how you can really start programming 40 00:01:51,180 --> 00:01:55,600 some really interesting behaviors and storing data, all kinds of things. 41 00:01:55,600 --> 00:01:58,180 And we actually use it as a bridge to text based programming. 42 00:01:58,180 --> 00:02:00,640 But I am primarily a high school teacher, 43 00:02:00,640 --> 00:02:03,650 and so it's going to be more from that perspective. 44 00:02:03,650 --> 00:02:07,540 Now, most of the demos today, just in the interest of time 45 00:02:07,540 --> 00:02:09,020 they're going to be in blocks. 46 00:02:09,020 --> 00:02:12,061 So we'll primarily be looking at the block based programming environment. 47 00:02:12,061 --> 00:02:16,120 But I don't want you to get the wrong idea here in the sense 48 00:02:16,120 --> 00:02:18,567 that you can do way more than just working with blocks. 49 00:02:18,567 --> 00:02:20,650 And in fact, everything that we do with the blocks 50 00:02:20,650 --> 00:02:24,490 here will translate directly over to JavaScript. 51 00:02:24,490 --> 00:02:29,500 And there'll be a lot of other kinds of resources 52 00:02:29,500 --> 00:02:34,940 for learning about how to program this in Python and other languages. 53 00:02:34,940 --> 00:02:38,740 So if we take a look at the idea of Microsoft MakeCode-- 54 00:02:38,740 --> 00:02:43,270 and now just like our own CS50 IDE, one of the advantages to MakeCode 55 00:02:43,270 --> 00:02:45,410 is that everything happens in a browser. 56 00:02:45,410 --> 00:02:48,815 So if you're using this on your own, if you're 57 00:02:48,815 --> 00:02:51,190 a high school teacher like me or a middle school teacher, 58 00:02:51,190 --> 00:02:54,280 you're using it with students, you can use it right on the web. 59 00:02:54,280 --> 00:02:58,660 If you just go to makecode.com, you'll get back to that title screen 60 00:02:58,660 --> 00:03:01,870 and then you can go to online editor. 61 00:03:01,870 --> 00:03:04,520 And the nice thing about it is you actually have a simulator, 62 00:03:04,520 --> 00:03:08,860 so even if you don't have a micro:bit you can see immediately what will 63 00:03:08,860 --> 00:03:10,360 happen in the simulator. 64 00:03:10,360 --> 00:03:14,060 And I'll show you some examples of that live. 65 00:03:14,060 --> 00:03:18,740 Again, like I said, we use this as a progression from blocks to text. 66 00:03:18,740 --> 00:03:21,620 And I can say having worked with many, many students 67 00:03:21,620 --> 00:03:26,960 that I believe that starting with blocks is a great way 68 00:03:26,960 --> 00:03:29,900 to start beginners to programming, because the blocks really 69 00:03:29,900 --> 00:03:32,600 get you the main concepts and the main ideas 70 00:03:32,600 --> 00:03:36,352 behind programming, iteration, conditionals, functions. 71 00:03:36,352 --> 00:03:38,060 But you don't have to worry about syntax. 72 00:03:38,060 --> 00:03:40,768 You don't get hung up with the fact that you missed a semi-colon, 73 00:03:40,768 --> 00:03:43,250 or you capitalized something a different way. 74 00:03:43,250 --> 00:03:46,940 So block based languages are a great way to start. 75 00:03:46,940 --> 00:03:50,000 And even for my students what we'll find is when we're 76 00:03:50,000 --> 00:03:51,510 trying to think through a problem-- 77 00:03:51,510 --> 00:03:55,130 and remember the programming really is a process of solving problems. 78 00:03:55,130 --> 00:03:58,200 Often, when students get stuck I'll say, well, 79 00:03:58,200 --> 00:04:00,230 how would you sell this in blocks? 80 00:04:00,230 --> 00:04:02,810 And they say, oh, well, I'd use this block and this block, 81 00:04:02,810 --> 00:04:04,610 and, oh OK, I get it now. 82 00:04:04,610 --> 00:04:06,767 And they'll know how to kind of-- 83 00:04:06,767 --> 00:04:08,100 and that happens to me, as well. 84 00:04:08,100 --> 00:04:11,183 So sometimes if you get stuck think about what the blocks would look like, 85 00:04:11,183 --> 00:04:13,220 and the blocks go right over to text. 86 00:04:13,220 --> 00:04:17,850 So let's take a look again at how this works. 87 00:04:17,850 --> 00:04:20,399 Again, MakeCode is a block based environment. 88 00:04:20,399 --> 00:04:22,640 MakeCode it also provides a JavaScript tabs, 89 00:04:22,640 --> 00:04:24,590 so you can tab right over to JavaScript. 90 00:04:24,590 --> 00:04:30,770 There are some things that you can do in JavaScript that you can't do in blocks. 91 00:04:30,770 --> 00:04:35,390 And so you can start if you are working in a block based project 92 00:04:35,390 --> 00:04:38,270 and you get stuck and you're like, I don't see the blocks here 93 00:04:38,270 --> 00:04:38,990 that are going to do this. 94 00:04:38,990 --> 00:04:41,540 I need to send parameters into a function or something like that, 95 00:04:41,540 --> 00:04:44,450 you can actually start writing your own functions and things in JavaScript. 96 00:04:44,450 --> 00:04:47,210 And they will show up as a custom block with a JavaScript embedded 97 00:04:47,210 --> 00:04:49,120 in the block. 98 00:04:49,120 --> 00:04:55,310 So don't worry, you can definitely go from blocks to Java and back again. 99 00:04:55,310 --> 00:04:57,350 There is a great editor called MicroPython. 100 00:04:57,350 --> 00:04:59,510 It's an editor that's called Mu. 101 00:04:59,510 --> 00:05:04,010 And MicroPython, you can also because we just started programming in Python, 102 00:05:04,010 --> 00:05:05,550 so it will look familiar to you. 103 00:05:05,550 --> 00:05:09,320 You can actually create Python based projects for the micro:bit. 104 00:05:09,320 --> 00:05:14,450 And again, all of those resources are here at tinyurl.com/micro:bitworkshop. 105 00:05:14,450 --> 00:05:16,080 So challenges for today. 106 00:05:16,080 --> 00:05:16,640 Here's what we're going to do. 107 00:05:16,640 --> 00:05:18,830 I'm going to give you an overview of the micro:bit hardware, 108 00:05:18,830 --> 00:05:21,996 we're going to download and run a few programs to kind of see how they work, 109 00:05:21,996 --> 00:05:25,460 I'm going to have you explore about two or three challenges just to give you 110 00:05:25,460 --> 00:05:27,935 an idea, give you a taste of some of the different things that you can do with 111 00:05:27,935 --> 00:05:30,726 the micro:bit, and then finally, I'll leave time for some questions 112 00:05:30,726 --> 00:05:31,380 and answers. 113 00:05:31,380 --> 00:05:34,610 So again, I work in a high school, middle school. 114 00:05:34,610 --> 00:05:37,880 These are some kinds of projects that students have done. 115 00:05:37,880 --> 00:05:41,730 I put this out here not as examples specifically of projects 116 00:05:41,730 --> 00:05:44,600 that you would do, but when you think about doing 117 00:05:44,600 --> 00:05:49,580 a project for CS50, what would happen if the code were not just confined 118 00:05:49,580 --> 00:05:51,650 to running on a screen? 119 00:05:51,650 --> 00:05:53,551 How could it go outside of that? 120 00:05:53,551 --> 00:05:55,550 There are all these different kinds of projects. 121 00:05:55,550 --> 00:05:57,341 And what I love about this is it allows you 122 00:05:57,341 --> 00:05:59,220 to really bring in your own creativity. 123 00:05:59,220 --> 00:06:03,630 And you can make something that you can actually use away from the computer. 124 00:06:03,630 --> 00:06:07,070 Here's an example of a milk carton robot. 125 00:06:07,070 --> 00:06:08,870 You'll notice there is the micro:bit. 126 00:06:08,870 --> 00:06:11,480 And we're using these crocodile clips to attach them 127 00:06:11,480 --> 00:06:14,270 to a servo motor on the inside. 128 00:06:14,270 --> 00:06:16,885 And so this kind of opens and closes. 129 00:06:16,885 --> 00:06:19,640 Now, the micro:bit is sensing the light. 130 00:06:19,640 --> 00:06:25,940 And that kind of allows you to create all kinds of interesting behaviors. 131 00:06:25,940 --> 00:06:27,870 Take a look at this one. 132 00:06:27,870 --> 00:06:29,625 So this is an air guitar demo so-- 133 00:06:29,625 --> 00:06:32,185 [AIR GUITAR] 134 00:06:32,185 --> 00:06:35,339 DOUGLAS KIANG: The micro:bits generating using great music. 135 00:06:35,339 --> 00:06:43,227 [AIR GUITAR] 136 00:06:43,227 --> 00:06:46,616 DOUGLAS KIANG: And think about what kind of inputs the micro:bit's taking in. 137 00:06:46,616 --> 00:06:48,157 How is it figuring out how to change? 138 00:06:48,157 --> 00:06:50,129 How's he changing the music? 139 00:06:50,129 --> 00:06:53,580 [AIR GUITAR] 140 00:06:53,580 --> 00:07:03,933 141 00:07:03,933 --> 00:07:07,772 DOUGLAS KIANG: So if you think about this idea-- 142 00:07:07,772 --> 00:07:08,730 come on in, come on in. 143 00:07:08,730 --> 00:07:10,490 So find an empty seat. 144 00:07:10,490 --> 00:07:14,891 And this actually demonstrates a couple of the different inputs 145 00:07:14,891 --> 00:07:15,640 on the micro:bits. 146 00:07:15,640 --> 00:07:18,230 So the micro:bit allows you to-- 147 00:07:18,230 --> 00:07:21,800 it has a sensor so it can tell which way it's tilted. 148 00:07:21,800 --> 00:07:24,260 So he's tilting the guitar and it's sensing 149 00:07:24,260 --> 00:07:28,484 based on the tilt what the angle of rotation is, 150 00:07:28,484 --> 00:07:31,150 and then it's changing the sound based on the angle of rotation. 151 00:07:31,150 --> 00:07:36,670 Now, the other thing about the micro:bit is it actually has a light sensor. 152 00:07:36,670 --> 00:07:38,100 And you have them on your table. 153 00:07:38,100 --> 00:07:39,766 You can kind of check them out yourself. 154 00:07:39,766 --> 00:07:44,690 But basically this is a five by five LED screen, and it also senses the light. 155 00:07:44,690 --> 00:07:48,400 So if you cover it, it can tell that the light has dimmed. 156 00:07:48,400 --> 00:07:53,960 So think about for your projects what potential that has for you to build 157 00:07:53,960 --> 00:07:57,110 in some different behaviors for the micro:bit based on how much light it 158 00:07:57,110 --> 00:07:59,360 detects. 159 00:07:59,360 --> 00:08:02,390 So think about the micro:bit as a way of taking in input. 160 00:08:02,390 --> 00:08:05,630 So we talked about rotation, talked about the light sensor. 161 00:08:05,630 --> 00:08:07,890 There are also different outputs. 162 00:08:07,890 --> 00:08:09,710 And so here's an example. 163 00:08:09,710 --> 00:08:12,950 This one was actually written-- 164 00:08:12,950 --> 00:08:16,470 this is JavaScript and this actually is going out 165 00:08:16,470 --> 00:08:17,986 to what's called a neo pixel strip. 166 00:08:17,986 --> 00:08:19,860 And a neo pixel strip is a plastic strip that 167 00:08:19,860 --> 00:08:23,500 has these embedded RGB, LEDs in them. 168 00:08:23,500 --> 00:08:26,130 And so he basically created bike lights with this. 169 00:08:26,130 --> 00:08:29,810 170 00:08:29,810 --> 00:08:31,660 Whoops. 171 00:08:31,660 --> 00:08:33,309 Let's see if I can get it to play. 172 00:08:33,309 --> 00:08:35,860 There we go. 173 00:08:35,860 --> 00:08:39,760 So he actually has a micrid mounted to this frame of his bike. 174 00:08:39,760 --> 00:08:43,450 And the neo pixel strips are pretty tough and they're weather resistant, 175 00:08:43,450 --> 00:08:45,880 and he just kind of stuck them along the side of the bike. 176 00:08:45,880 --> 00:08:49,840 And so you can create custom lighting displays using the micro:bit, 177 00:08:49,840 --> 00:08:51,610 using code essentially. 178 00:08:51,610 --> 00:08:53,470 So it's very cool. 179 00:08:53,470 --> 00:08:56,630 What I love about the micro:bit is because it's so small and lightweight 180 00:08:56,630 --> 00:08:59,020 you can embed it into things like wearables. 181 00:08:59,020 --> 00:09:01,690 So this is an activity we did with young kids, 182 00:09:01,690 --> 00:09:05,660 but you could certainly adapt this into fabrics, for example. 183 00:09:05,660 --> 00:09:11,110 So we give a picture frame, and we just put out two strips of duct tape and you 184 00:09:11,110 --> 00:09:15,130 stick the micro:bit onto the duct tape, and then you cut the tape off 185 00:09:15,130 --> 00:09:16,420 of the frame. 186 00:09:16,420 --> 00:09:22,060 And basically you can use Velcro tabs and you can actually create a wristband 187 00:09:22,060 --> 00:09:23,470 for the micro:bit. 188 00:09:23,470 --> 00:09:27,190 So I had a student who was a-- 189 00:09:27,190 --> 00:09:29,170 he was a pitcher baseball pitcher. 190 00:09:29,170 --> 00:09:32,140 And he actually programmed the micro:bit to be a pitch counter. 191 00:09:32,140 --> 00:09:35,380 So as many times as he threw pitches in a session, 192 00:09:35,380 --> 00:09:38,590 every time it detected the acceleration of his arm 193 00:09:38,590 --> 00:09:40,360 it counted that as one pitch. 194 00:09:40,360 --> 00:09:44,830 And so after throwing a bunch of times in a session he could come back 195 00:09:44,830 --> 00:09:49,120 and it would actually show how many pitches he'd thrown. 196 00:09:49,120 --> 00:09:50,320 So kind of neat. 197 00:09:50,320 --> 00:09:54,160 So if you think about all the possibilities 198 00:09:54,160 --> 00:09:59,276 that watch based technologies give us in terms of collecting data, storing data, 199 00:09:59,276 --> 00:10:01,900 and then displaying the data or displaying the values of things 200 00:10:01,900 --> 00:10:03,792 that it's measured. 201 00:10:03,792 --> 00:10:07,000 When I think about that I start thinking about some really neat possibilities 202 00:10:07,000 --> 00:10:09,310 with using the micro:bits. 203 00:10:09,310 --> 00:10:12,880 I was out in San Mateo at the Maker Faire 204 00:10:12,880 --> 00:10:16,660 and they actually had a wearable fashion show. 205 00:10:16,660 --> 00:10:20,630 And so this is a dress that she made and she embedded lights. 206 00:10:20,630 --> 00:10:21,550 And you can do this. 207 00:10:21,550 --> 00:10:25,300 I don't know if she used the micro:bit, but she used a microprocessor like 208 00:10:25,300 --> 00:10:31,165 the micro:bit to talk to embedded sewn in pieces of light essentially 209 00:10:31,165 --> 00:10:32,560 the light strips. 210 00:10:32,560 --> 00:10:38,560 So if you work with clothing or fabrics, textiles, 211 00:10:38,560 --> 00:10:43,390 think about how might you sew in some different kinds of circuits and use 212 00:10:43,390 --> 00:10:45,650 the micro:bit to control them. 213 00:10:45,650 --> 00:10:49,470 I think that would be a really interesting project. 214 00:10:49,470 --> 00:10:50,910 Here are some other examples. 215 00:10:50,910 --> 00:10:52,269 And they use this-- 216 00:10:52,269 --> 00:10:54,060 there are a lot of maker spaces around here 217 00:10:54,060 --> 00:10:57,000 that will allow you to use things like laser cutters. 218 00:10:57,000 --> 00:11:02,820 So she actually laser cut a beautiful design into the dress. 219 00:11:02,820 --> 00:11:06,630 This really helps to combine things that you love 220 00:11:06,630 --> 00:11:10,280 with computing and with programming. 221 00:11:10,280 --> 00:11:12,530 This is another thing that was kind of cool. 222 00:11:12,530 --> 00:11:21,700 So this was a fashion show that was put on by and for models who are amputees. 223 00:11:21,700 --> 00:11:25,360 So these models are double amputees, but they've actually 224 00:11:25,360 --> 00:11:31,610 got these legs that are programmed with different designs and patterns 225 00:11:31,610 --> 00:11:35,210 based on their movements. 226 00:11:35,210 --> 00:11:36,900 And so there's this little fashion show. 227 00:11:36,900 --> 00:11:43,090 So I love this idea of let's take assisted technologies 228 00:11:43,090 --> 00:11:45,220 and make them something that's visually appealing 229 00:11:45,220 --> 00:11:47,950 and make it something that's actually kind of interesting 230 00:11:47,950 --> 00:11:51,440 and cool to look at, as well. 231 00:11:51,440 --> 00:11:53,720 And again, if you're going to do something like this, 232 00:11:53,720 --> 00:11:57,380 you need a microprocessor, you need some kind of a brain. 233 00:11:57,380 --> 00:11:59,770 So these things are like 16 bucks. 234 00:11:59,770 --> 00:12:02,830 We have a few of them here, so if you're interested in using 235 00:12:02,830 --> 00:12:06,040 this for a project come talk to me, let me know. 236 00:12:06,040 --> 00:12:07,870 We can support you. 237 00:12:07,870 --> 00:12:09,850 You can borrow these. 238 00:12:09,850 --> 00:12:11,890 and use them for the duration of your project. 239 00:12:11,890 --> 00:12:15,014 And then if you wanted to purchase it there's links that are purchase them. 240 00:12:15,014 --> 00:12:17,180 They're not that expensive. 241 00:12:17,180 --> 00:12:18,657 The hardware itself. 242 00:12:18,657 --> 00:12:21,490 Remember if we go back to week zero when we talked about a computer, 243 00:12:21,490 --> 00:12:25,300 if you think about a computer is basically a CPU or a processor. 244 00:12:25,300 --> 00:12:30,100 That brings in inputs and outputs it in some way. 245 00:12:30,100 --> 00:12:32,500 The micro:bit, same thing. 246 00:12:32,500 --> 00:12:35,140 The micro:bit basically has a number of inputs. 247 00:12:35,140 --> 00:12:38,770 And if you look on this diagram, you can see some of the different inputs. 248 00:12:38,770 --> 00:12:41,770 We talked a little bit before about there's an accelerometer, 249 00:12:41,770 --> 00:12:46,090 there's actually a compass, so it can detect which way it's being turned. 250 00:12:46,090 --> 00:12:48,490 So you can take it and you can actually turn it 251 00:12:48,490 --> 00:12:53,320 and it will detect what direction it's facing, which is kind of interesting. 252 00:12:53,320 --> 00:12:54,830 It has an accelerometer. 253 00:12:54,830 --> 00:13:00,460 So it can detect how it's been shaken or moved. 254 00:13:00,460 --> 00:13:02,940 Basically, it has a light sensor, as well, 255 00:13:02,940 --> 00:13:05,320 and also, of course, has conventional input. 256 00:13:05,320 --> 00:13:06,130 There are buttons. 257 00:13:06,130 --> 00:13:10,141 So there's the a button, the b button and the a and b together. 258 00:13:10,141 --> 00:13:11,890 And if we press both of those together you 259 00:13:11,890 --> 00:13:15,820 can actually get a third behavior there. 260 00:13:15,820 --> 00:13:22,450 And you have digital and analog outputs here, as well as inputs, 261 00:13:22,450 --> 00:13:26,969 and you have a micro USB connector. 262 00:13:26,969 --> 00:13:30,010 And that connects it to the computer so that you can actually program it. 263 00:13:30,010 --> 00:13:34,020 So some different accessories that we use with it. 264 00:13:34,020 --> 00:13:37,360 So we use crocodile clips that are very easy to connect 265 00:13:37,360 --> 00:13:40,840 to different things like servo motors or lights 266 00:13:40,840 --> 00:13:44,920 or pretty much anything that will work with something, like Arduino, 267 00:13:44,920 --> 00:13:47,860 for example, like those kinds of accessories 268 00:13:47,860 --> 00:13:51,290 you can plug them in on these. 269 00:13:51,290 --> 00:13:55,119 This basically comes with the battery pack and the US cable. 270 00:13:55,119 --> 00:13:57,910 The battery pack allows you to use it separately from the computer. 271 00:13:57,910 --> 00:14:01,990 When you have it plugged into your computer it's powered off the USB. 272 00:14:01,990 --> 00:14:05,230 If you have a pair of ear buds you can actually use a crocodile clips 273 00:14:05,230 --> 00:14:08,500 to connect the ear buds to the micro:bits. 274 00:14:08,500 --> 00:14:10,700 So you can actually hear, it has a tone generator. 275 00:14:10,700 --> 00:14:13,330 So you can actually create music. 276 00:14:13,330 --> 00:14:15,925 I've had students create the entire Legend of Zelda theme off 277 00:14:15,925 --> 00:14:17,596 of the micro:bit. 278 00:14:17,596 --> 00:14:19,470 And if you think back to some of the problems 279 00:14:19,470 --> 00:14:21,430 that we've had that dealt with music, there 280 00:14:21,430 --> 00:14:26,210 might be interesting things you can do with scales or other kinds of things. 281 00:14:26,210 --> 00:14:27,480 There's lots of maker kits. 282 00:14:27,480 --> 00:14:31,030 So you can get the bare bones package or you can get it 283 00:14:31,030 --> 00:14:33,520 as a kit, which will come with like a bunch of other stuff 284 00:14:33,520 --> 00:14:34,770 that you can play around with. 285 00:14:34,770 --> 00:14:36,820 So some cool stuff. 286 00:14:36,820 --> 00:14:38,680 But let's try working with them right now. 287 00:14:38,680 --> 00:14:41,580 If you want to go ahead and pull out if you have a laptop, 288 00:14:41,580 --> 00:14:47,080 just if you pull out a laptop and you go to makecode.com, 289 00:14:47,080 --> 00:14:53,060 there is a link to micro:bit, and you'll see it on the left. 290 00:14:53,060 --> 00:14:56,840 If you just click the micro:bit it'll open it up in a browser. 291 00:14:56,840 --> 00:15:00,680 292 00:15:00,680 --> 00:15:02,570 And I'll just sort of walk you through. 293 00:15:02,570 --> 00:15:06,260 And I basically passed out these micro:bits because I want you to kind 294 00:15:06,260 --> 00:15:08,390 of have a chance to play around with them. 295 00:15:08,390 --> 00:15:11,090 Later on at home if you want to play with the simulator, pretty 296 00:15:11,090 --> 00:15:14,360 much anything you can program here you'll see on the simulator. 297 00:15:14,360 --> 00:15:17,390 And you can even simulate holding it in different ways 298 00:15:17,390 --> 00:15:19,920 and shaking it and those kinds of things. 299 00:15:19,920 --> 00:15:23,460 But I actually like working with the actual physical micro:bit. 300 00:15:23,460 --> 00:15:31,320 At least while you're here work with the micro:bit and try it out in real life. 301 00:15:31,320 --> 00:15:35,150 So this is what the interface actually looks like. 302 00:15:35,150 --> 00:15:36,960 All the projects are stored locally. 303 00:15:36,960 --> 00:15:40,060 So on your computer, they're stored on your computer itself. 304 00:15:40,060 --> 00:15:43,940 So they're not cloud based at all. 305 00:15:43,940 --> 00:15:45,655 So you don't need to sign in. 306 00:15:45,655 --> 00:15:47,780 As long as you're using the same computer, whenever 307 00:15:47,780 --> 00:15:53,922 you click on Projects you'll see all the projects that you've been working on. 308 00:15:53,922 --> 00:15:55,880 You can program in either blocks or JavaScript. 309 00:15:55,880 --> 00:15:58,180 And as I said earlier, we'll primarily stay in blocks 310 00:15:58,180 --> 00:15:59,930 but if you're ever curious and if you want 311 00:15:59,930 --> 00:16:02,702 to just click JavaScript you'll see what all the equivalent of it 312 00:16:02,702 --> 00:16:04,410 looks in JavaScript and if you wanted to, 313 00:16:04,410 --> 00:16:07,280 you could just program it in JavaScript directly if you wanted. 314 00:16:07,280 --> 00:16:09,639 I usually start with blocks. 315 00:16:09,639 --> 00:16:11,180 This is what we call a block toolbox. 316 00:16:11,180 --> 00:16:12,140 So these are all the drawers. 317 00:16:12,140 --> 00:16:13,490 This is very much like scratch. 318 00:16:13,490 --> 00:16:17,840 So you'll have lots of different drawers at different kinds of inputs, 319 00:16:17,840 --> 00:16:21,620 different kinds of blocks here, you drag the blocks into the coding workspace. 320 00:16:21,620 --> 00:16:24,200 That's where you're going to build your program. 321 00:16:24,200 --> 00:16:28,640 You can actually download the program directly as a file. 322 00:16:28,640 --> 00:16:31,030 And that's what you'll drag on to your micro:bit. 323 00:16:31,030 --> 00:16:34,279 So when you plug the micro:bit in, and you can go ahead and plug the micro bit 324 00:16:34,279 --> 00:16:38,360 in now, if you like just plug it right into your USB port, 325 00:16:38,360 --> 00:16:39,710 it'll show up like a volume. 326 00:16:39,710 --> 00:16:41,920 It'll show up like a hard drive basically. 327 00:16:41,920 --> 00:16:45,530 And the way that you load programs onto it is you just drag that program right 328 00:16:45,530 --> 00:16:48,070 onto the micro:bit itself. 329 00:16:48,070 --> 00:16:48,570 Yeah. 330 00:16:48,570 --> 00:16:49,159 So this is it. 331 00:16:49,159 --> 00:16:52,200 So you can play around with it, you'll see what the simulator looks like. 332 00:16:52,200 --> 00:16:54,180 So let's start with programming an animation. 333 00:16:54,180 --> 00:16:56,930 So if you go ahead and open the Basic Toolbox drawer, 334 00:16:56,930 --> 00:17:00,352 you can drag two of these show LED blocks onto your workspace, 335 00:17:00,352 --> 00:17:02,810 and then you can position them underneath the Forever block 336 00:17:02,810 --> 00:17:06,876 to look kind of just like that. 337 00:17:06,876 --> 00:17:08,750 You'll notice there's a few other things too. 338 00:17:08,750 --> 00:17:09,660 While you're doing that. 339 00:17:09,660 --> 00:17:10,618 I'll just keep talking. 340 00:17:10,618 --> 00:17:14,839 But you can actually not just show LEDs, but there are actually patterns. 341 00:17:14,839 --> 00:17:17,359 So there are pre-built programs that are built in so you 342 00:17:17,359 --> 00:17:19,430 can make it look like as a heart shape. 343 00:17:19,430 --> 00:17:21,829 There's other kinds of things you can show LEDs here. 344 00:17:21,829 --> 00:17:24,079 You can also show numbers. 345 00:17:24,079 --> 00:17:26,839 And this is actually very valuable because I use 346 00:17:26,839 --> 00:17:28,700 this to show the values of variables. 347 00:17:28,700 --> 00:17:30,449 I've been working with variables or if I'd 348 00:17:30,449 --> 00:17:33,950 like to display what the current reading is off of a sensor, 349 00:17:33,950 --> 00:17:36,270 you can just drag that block right in here. 350 00:17:36,270 --> 00:17:39,710 And then you can actually see what that sensor readout is. 351 00:17:39,710 --> 00:17:44,000 And when you say show number, it will display it directly to the screen 352 00:17:44,000 --> 00:17:46,890 of the micro:bit, or if it's a long number it'll scroll it across 353 00:17:46,890 --> 00:17:47,390 the screen. 354 00:17:47,390 --> 00:17:50,310 355 00:17:50,310 --> 00:17:53,270 So once you've moved these in you can shy 356 00:17:53,270 --> 00:17:55,490 showing some of these different things. 357 00:17:55,490 --> 00:17:57,560 You'll notice that the animation will show up 358 00:17:57,560 --> 00:18:02,550 in the simulator on the upper left hand side of your screen. 359 00:18:02,550 --> 00:18:05,810 And you can even try the Show Icon block, 360 00:18:05,810 --> 00:18:12,260 which is what I was talking about where you have built in designs. 361 00:18:12,260 --> 00:18:15,650 You can experiment with different kinds of animations, 362 00:18:15,650 --> 00:18:17,507 all kinds of cool things. 363 00:18:17,507 --> 00:18:19,840 And then I'm going to go over to downloading the program 364 00:18:19,840 --> 00:18:20,740 to the micro:bits. 365 00:18:20,740 --> 00:18:24,010 And once you have that just, this is what you would essentially do. 366 00:18:24,010 --> 00:18:27,160 You're going to plug the micro:bit in with the USB cable. 367 00:18:27,160 --> 00:18:30,470 If you click the Download button, it actually saves it onto your hard drive. 368 00:18:30,470 --> 00:18:34,570 If you are using Microsoft Edge you can choose Save As and that will save it 369 00:18:34,570 --> 00:18:35,950 onto your micro:bit hard drive. 370 00:18:35,950 --> 00:18:39,430 So download button looks like that, Save As will look like that. 371 00:18:39,430 --> 00:18:41,960 You can save it directly onto the micro:bit volume, 372 00:18:41,960 --> 00:18:44,170 which will come up kind of like-- 373 00:18:44,170 --> 00:18:47,620 it'll look just sort of like that micro:bit volume there. 374 00:18:47,620 --> 00:18:51,430 With Google Chrome you can go to your Downloads folder 375 00:18:51,430 --> 00:18:52,870 and you can just drag copy it. 376 00:18:52,870 --> 00:18:55,001 377 00:18:55,001 --> 00:18:57,750 You don't need to worry about managing the files in the micro:bit. 378 00:18:57,750 --> 00:19:00,291 It only holds one at a time anyway, so you drag it over there 379 00:19:00,291 --> 00:19:01,770 it'll just replace what's there. 380 00:19:01,770 --> 00:19:04,364 And then it'll show up actually on the micro:bit itself, 381 00:19:04,364 --> 00:19:05,280 which is kind of cool. 382 00:19:05,280 --> 00:19:08,520 383 00:19:08,520 --> 00:19:14,870 So I think the goal is to primarily get you to the point where you can download 384 00:19:14,870 --> 00:19:19,461 a file to your hard drive and then put it onto the micro:bit, 385 00:19:19,461 --> 00:19:21,210 so that it actually runs on the micro:bit. 386 00:19:21,210 --> 00:19:23,640 That would be the goal ideally. 387 00:19:23,640 --> 00:19:29,400 Get to that point and then anything that you create in the project's coding 388 00:19:29,400 --> 00:19:34,217 workspace, you'll know how to move it onto your micro:bit itself. 389 00:19:34,217 --> 00:19:37,550 Now one of the other things to notice is there's lots of other different things. 390 00:19:37,550 --> 00:19:40,010 So you can say on button A press, so you could make it 391 00:19:40,010 --> 00:19:42,710 when you press button a display one thing, 392 00:19:42,710 --> 00:19:47,140 but when you press button b you have it display something else. 393 00:19:47,140 --> 00:19:51,370 And so that's kind of neat to do as well. 394 00:19:51,370 --> 00:19:54,340 395 00:19:54,340 --> 00:19:56,275 Let me actually go over to-- 396 00:19:56,275 --> 00:19:58,920 397 00:19:58,920 --> 00:20:02,662 I'm going to switch over to the Make Code environment itself 398 00:20:02,662 --> 00:20:04,870 and we'll kind of play around a little bit with this. 399 00:20:04,870 --> 00:20:16,020 400 00:20:16,020 --> 00:20:18,390 So you'll notice that in the loops you basically 401 00:20:18,390 --> 00:20:21,375 have a forever loop which just runs as soon as the program starts 402 00:20:21,375 --> 00:20:22,250 it just runs forever. 403 00:20:22,250 --> 00:20:23,970 It's like a while true. 404 00:20:23,970 --> 00:20:26,070 You also have on start which will run just once. 405 00:20:26,070 --> 00:20:29,629 And I usually use this to initialize variables and things like that, 406 00:20:29,629 --> 00:20:31,170 that I just want to have happen once. 407 00:20:31,170 --> 00:20:36,870 408 00:20:36,870 --> 00:20:40,061 These inputs, these are essentially event handlers 409 00:20:40,061 --> 00:20:41,310 which just sit there and wait. 410 00:20:41,310 --> 00:20:42,150 They listen. 411 00:20:42,150 --> 00:20:45,270 It's a listener for if button a is pressed, 412 00:20:45,270 --> 00:20:47,770 then we're going to display something specific. 413 00:20:47,770 --> 00:20:51,739 So for instance, maybe we show a heart icon when a button is pressed. 414 00:20:51,739 --> 00:20:54,780 The other thing that's cool is if you highlight this, if you click on it, 415 00:20:54,780 --> 00:20:58,840 you click copy and paste, you can paste in another one. 416 00:20:58,840 --> 00:21:02,456 This one's grayed out because you can't have two events that 417 00:21:02,456 --> 00:21:04,080 happen when the same button is pressed. 418 00:21:04,080 --> 00:21:07,750 But I can use this to change it over to a button b, and I can say, 419 00:21:07,750 --> 00:21:12,000 let's choose something like a house when that's pressed. 420 00:21:12,000 --> 00:21:16,170 So you can create different kinds of event handlers that way. 421 00:21:16,170 --> 00:21:22,450 422 00:21:22,450 --> 00:21:24,720 Another thing that you can do is when you're 423 00:21:24,720 --> 00:21:28,890 done with these, if you click on Share, if you click the Share button you 424 00:21:28,890 --> 00:21:31,440 can actually publish the project. 425 00:21:31,440 --> 00:21:34,780 And when you publish the project it actually shares it using URL. 426 00:21:34,780 --> 00:21:42,070 So that URL is essentially the program that I've just created. 427 00:21:42,070 --> 00:21:45,571 So if I open up another thing in my browser and I just go to-- 428 00:21:45,571 --> 00:21:49,970 429 00:21:49,970 --> 00:21:51,949 you'll notice that it shows up here. 430 00:21:51,949 --> 00:21:53,990 And if you go to the JavaScript, you can actually 431 00:21:53,990 --> 00:21:55,520 see what the JavaScript looks like. 432 00:21:55,520 --> 00:21:58,400 So this is an on-button press, and then you've got, 433 00:21:58,400 --> 00:22:00,830 essentially, the action underneath. 434 00:22:00,830 --> 00:22:07,730 So this is the event, and then this is the resulting action from that event. 435 00:22:07,730 --> 00:22:10,970 You can take this, and you can download it. 436 00:22:10,970 --> 00:22:14,840 And then you can drag copy that file directly onto your micro:bit. 437 00:22:14,840 --> 00:22:16,740 So you can try out somebody else's code. 438 00:22:16,740 --> 00:22:23,582 The other thing that you can do is, you can basically copy all of that text, 439 00:22:23,582 --> 00:22:25,790 go back to your main code-- well this will make sense 440 00:22:25,790 --> 00:22:28,077 because this is the same program. 441 00:22:28,077 --> 00:22:31,160 But if you created a new project, for example, and let's say somebody else 442 00:22:31,160 --> 00:22:32,150 wrote that. 443 00:22:32,150 --> 00:22:37,050 You go over to JavaScript, and just paste in that code. 444 00:22:37,050 --> 00:22:41,260 And now if you go back to blocks, it's all there. 445 00:22:41,260 --> 00:22:47,950 So you can easily, kind of, remix other projects, you can share projects. 446 00:22:47,950 --> 00:22:50,320 And the other thing that projects will do 447 00:22:50,320 --> 00:22:54,297 is, if you have any HEX file that you've actually downloaded, 448 00:22:54,297 --> 00:22:57,130 you can actually import the file, and that will open it and bring it 449 00:22:57,130 --> 00:22:58,870 into your computer. 450 00:22:58,870 --> 00:23:02,230 So for the next challenge, what I'd like to do 451 00:23:02,230 --> 00:23:08,270 is I'd like to have you take a look at this one broken program that I created. 452 00:23:08,270 --> 00:23:12,440 So if we go over to-- 453 00:23:12,440 --> 00:23:20,570 it's basically shout key dot com slash lychee. 454 00:23:20,570 --> 00:23:24,200 And this is a temporary link. 455 00:23:24,200 --> 00:23:25,970 So this won't work after the fact. 456 00:23:25,970 --> 00:23:29,150 But all of these are linked from the actual resources 457 00:23:29,150 --> 00:23:34,980 sheet that is at the beginning of this presentation. 458 00:23:34,980 --> 00:23:39,765 But for today anyway, if you go to this URL, 459 00:23:39,765 --> 00:23:42,890 it's just a quick URL that's going to bring you up to the board game arrow. 460 00:23:42,890 --> 00:23:45,650 If you're watching this later, if you're not watching this live, 461 00:23:45,650 --> 00:23:49,610 go back to tiny URL dot com slash micro:bit workshop. 462 00:23:49,610 --> 00:23:52,940 And you'll see a link, board game arrow challenge one, there. 463 00:23:52,940 --> 00:23:55,750 And that's actually the make code link, that's the permanent link. 464 00:23:55,750 --> 00:23:58,430 But if you go to shoutkey dot com slash lychee, 465 00:23:58,430 --> 00:24:03,680 you'll come up with a program that I just shared that here's-- 466 00:24:03,680 --> 00:24:05,347 I'll show you what I want to do with it. 467 00:24:05,347 --> 00:24:08,305 You know, you ever played those board games where you have the spinner, 468 00:24:08,305 --> 00:24:09,800 and you kind of spin the spinner? 469 00:24:09,800 --> 00:24:11,840 Essentially, what I want to have happen here is, 470 00:24:11,840 --> 00:24:17,520 I want to have it so when you shake it, it spins automatically. 471 00:24:17,520 --> 00:24:20,395 And when it spins-- 472 00:24:20,395 --> 00:24:22,770 one of the neat things when you share a project is you'll 473 00:24:22,770 --> 00:24:24,340 actually see it running in the simulator. 474 00:24:24,340 --> 00:24:26,131 So this is what it's supposed to look like. 475 00:24:26,131 --> 00:24:28,920 If I click shake, the spinner spins. 476 00:24:28,920 --> 00:24:30,400 And you see how it slows down? 477 00:24:30,400 --> 00:24:33,770 478 00:24:33,770 --> 00:24:37,140 Just like a regular spinner, at some point it'll stop. 479 00:24:37,140 --> 00:24:39,827 And where the arrow stops, then that's maybe the direction 480 00:24:39,827 --> 00:24:41,660 that you move if you have a board game where 481 00:24:41,660 --> 00:24:43,760 you can move in one of four directions. 482 00:24:43,760 --> 00:24:46,760 And then somebody else can shake it, and it'll spin again, 483 00:24:46,760 --> 00:24:49,712 and then it'll slow down, and it'll stop. 484 00:24:49,712 --> 00:24:50,920 So that's the idea behind it. 485 00:24:50,920 --> 00:24:54,770 486 00:24:54,770 --> 00:24:57,770 So here's a programming, kind of what I think of as a little programming 487 00:24:57,770 --> 00:24:58,910 puzzle, to figure out. 488 00:24:58,910 --> 00:25:01,170 So here's how it actually works. 489 00:25:01,170 --> 00:25:03,260 So I've created some variables here. 490 00:25:03,260 --> 00:25:07,370 I've created a variable called delay. 491 00:25:07,370 --> 00:25:09,560 And when I shake it, it's going to clear anything 492 00:25:09,560 --> 00:25:11,120 that's currently on the screen. 493 00:25:11,120 --> 00:25:13,164 It's going to set the delay to zero. 494 00:25:13,164 --> 00:25:14,330 And then we will while loop. 495 00:25:14,330 --> 00:25:18,590 So while delay is less than 500, we're going to show the left arrow. 496 00:25:18,590 --> 00:25:21,170 We're going to pause, delay, amount of times. 497 00:25:21,170 --> 00:25:25,820 And delay is the amount of milliseconds. 498 00:25:25,820 --> 00:25:32,110 And then it's going to show the next frame of the arrow, 499 00:25:32,110 --> 00:25:35,470 and it's going to pause for some number of milliseconds, 500 00:25:35,470 --> 00:25:38,230 delay amount of milliseconds. 501 00:25:38,230 --> 00:25:40,910 And then after it shows all four of these, 502 00:25:40,910 --> 00:25:42,990 we're going to change delay by 150. 503 00:25:42,990 --> 00:25:46,390 And that basically means delay equals delay plus 150. 504 00:25:46,390 --> 00:25:51,100 So delay starts at zero, so it's pretty much no delay first time around. 505 00:25:51,100 --> 00:25:54,070 Then it's 150 milliseconds between frames. 506 00:25:54,070 --> 00:25:57,640 And then it's 300, and then it's 450. 507 00:25:57,640 --> 00:26:05,390 And then, when it becomes 600, this is no longer true. 508 00:26:05,390 --> 00:26:09,860 Ad soon as delay becomes 600, this isn't sure anymore, 509 00:26:09,860 --> 00:26:11,550 and so it should just stop. 510 00:26:11,550 --> 00:26:14,660 And because we haven't issued a clear screen, it's going to show, 511 00:26:14,660 --> 00:26:17,740 essentially, the down arrow. 512 00:26:17,740 --> 00:26:19,900 And that's where the problem is. 513 00:26:19,900 --> 00:26:25,000 I implemented this delay so that it starts fast and it kind of slows down. 514 00:26:25,000 --> 00:26:29,690 But it always shows the down arrow, so you're always going to be moving down. 515 00:26:29,690 --> 00:26:33,680 So that's kind of the problem. 516 00:26:33,680 --> 00:26:37,530 So this is just one of those problems that you run into with programming. 517 00:26:37,530 --> 00:26:40,250 And you know, it's sort of like, OK I had this idea, 518 00:26:40,250 --> 00:26:45,110 how can I change this so that the arrow points in a random direction? 519 00:26:45,110 --> 00:26:49,430 Because what I'd like to have it do is, I want it to basically decay. 520 00:26:49,430 --> 00:26:52,410 I wanted it to start at zero, and then slow down, slow down, slow down, 521 00:26:52,410 --> 00:26:52,910 slow down. 522 00:26:52,910 --> 00:26:56,710 And at some point when it slows down after a certain threshold, 523 00:26:56,710 --> 00:26:59,129 then I want it to stop spinning the arrow, 524 00:26:59,129 --> 00:27:01,170 and I want the arrow to just stop wherever it is. 525 00:27:01,170 --> 00:27:03,980 So as soon as it passes that threshold, I want it to stop 526 00:27:03,980 --> 00:27:06,490 and whatever frame the arrow is currently at. 527 00:27:06,490 --> 00:27:11,340 So think about how could we modify this code, 528 00:27:11,340 --> 00:27:14,510 how do we modify this program so that the arrow always 529 00:27:14,510 --> 00:27:16,716 lands in the same place? 530 00:27:16,716 --> 00:27:19,340 So take about five minutes, talk with the people at your table, 531 00:27:19,340 --> 00:27:20,360 figure this out. 532 00:27:20,360 --> 00:27:23,347 And we'll come back again, and we'll kind of 533 00:27:23,347 --> 00:27:24,680 think about how that might work. 534 00:27:24,680 --> 00:27:26,971 And meanwhile, while you're doing that, let me go ahead 535 00:27:26,971 --> 00:27:30,290 and I'm going to go through the process of downloading this and importing 536 00:27:30,290 --> 00:27:32,820 it to MakeCode so that you can see what's happening. 537 00:27:32,820 --> 00:27:39,460 So you can talk amongst yourselves, but I'm going to talk as well. 538 00:27:39,460 --> 00:27:41,799 So I'm going to download this first, and that's 539 00:27:41,799 --> 00:27:43,340 going to go into my downloads folder. 540 00:27:43,340 --> 00:27:47,120 541 00:27:47,120 --> 00:27:51,140 And then back here in MakeCode in my IDE. 542 00:27:51,140 --> 00:27:53,710 I'm going to go over to projects. 543 00:27:53,710 --> 00:27:57,680 And I'm going to choose import file, and this 544 00:27:57,680 --> 00:28:00,920 will allow me to actually choose it from my downloads. 545 00:28:00,920 --> 00:28:03,170 And this is the board game arrow that just came over. 546 00:28:03,170 --> 00:28:06,600 So I'm going to choose open. 547 00:28:06,600 --> 00:28:10,050 And then I'm going to choose go ahead. 548 00:28:10,050 --> 00:28:12,450 And what that will do, remember that that's 549 00:28:12,450 --> 00:28:16,800 a file that I downloaded from the shared projects. 550 00:28:16,800 --> 00:28:19,650 And you can import a HEX file directly into MakeCode, 551 00:28:19,650 --> 00:28:24,685 and so now we have actually these arrows. 552 00:28:24,685 --> 00:28:27,540 553 00:28:27,540 --> 00:28:35,660 So any ideas to start out with about how we might get this to work properly? 554 00:28:35,660 --> 00:28:43,430 555 00:28:43,430 --> 00:28:47,070 I mean one of the things, when I play board games, 556 00:28:47,070 --> 00:28:49,036 the reason the arrow doesn't-- 557 00:28:49,036 --> 00:28:50,910 you know if you were playing against a robot, 558 00:28:50,910 --> 00:28:53,940 and the robot could flick the arrow with exactly the same power 559 00:28:53,940 --> 00:28:58,920 every single time, it would always land at the same place every single time. 560 00:28:58,920 --> 00:29:00,540 So that wouldn't be much fun. 561 00:29:00,540 --> 00:29:05,220 So I think that what makes the board game spinner kind of interesting 562 00:29:05,220 --> 00:29:08,700 is that humans are always going to flick the arrow with slightly 563 00:29:08,700 --> 00:29:11,020 different amounts of force. 564 00:29:11,020 --> 00:29:15,570 And if you assume that the decay decays at the same rate, then 565 00:29:15,570 --> 00:29:21,330 the amount of force, in other words maybe where it starts, changes. 566 00:29:21,330 --> 00:29:26,510 So suppose we flipped it and we said, well, decay is greater than zero. 567 00:29:26,510 --> 00:29:32,077 But where it starts is some random number between like 600 and 800, 568 00:29:32,077 --> 00:29:32,910 something like that. 569 00:29:32,910 --> 00:29:35,820 I mean we could we could try that. 570 00:29:35,820 --> 00:29:37,860 And it's easy enough to do it here. 571 00:29:37,860 --> 00:29:40,510 If you just say, you can change this. 572 00:29:40,510 --> 00:29:43,737 573 00:29:43,737 --> 00:29:45,590 Wait a second, let me pull this away here. 574 00:29:45,590 --> 00:29:55,020 575 00:29:55,020 --> 00:29:56,937 That's kind of funny. 576 00:29:56,937 --> 00:29:59,520 I don't know if the blocks are like, the blocks or like stuck. 577 00:29:59,520 --> 00:30:02,760 Let me try copying this. 578 00:30:02,760 --> 00:30:05,930 And let me go over and start a new project. 579 00:30:05,930 --> 00:30:08,514 Just out of curiosity, I'm going to flop back into JavaScript. 580 00:30:08,514 --> 00:30:11,138 And this is actually what it looks like in JavaScript, which is 581 00:30:11,138 --> 00:30:13,040 kind of neat, all of this stuff here. 582 00:30:13,040 --> 00:30:15,248 And then it should change it over to blocks directly. 583 00:30:15,248 --> 00:30:18,780 584 00:30:18,780 --> 00:30:21,050 And now we can separate them. 585 00:30:21,050 --> 00:30:26,370 This, let's change this over to greater than, and we'll make it zero. 586 00:30:26,370 --> 00:30:32,050 So while it's greater than zero, we're going to continue to do something. 587 00:30:32,050 --> 00:30:35,200 And then let's change the delay-- 588 00:30:35,200 --> 00:30:38,230 this time if we want to change it, going back the other way, 589 00:30:38,230 --> 00:30:41,080 if we want the same rate of decay, we could just 590 00:30:41,080 --> 00:30:44,030 basically set that to be negative. 591 00:30:44,030 --> 00:30:45,800 So now we're going backwards. 592 00:30:45,800 --> 00:30:50,140 So what we've just done by changing two things is, we've gone backwards. 593 00:30:50,140 --> 00:30:52,480 Now we're basically running the thing, we're 594 00:30:52,480 --> 00:30:58,149 starting delay at some big number, like you know, I don't know, 500. 595 00:30:58,149 --> 00:30:59,440 And then we'll actually run it. 596 00:30:59,440 --> 00:31:02,702 And notice that as soon as I make the change, it'll get reflected up here. 597 00:31:02,702 --> 00:31:04,160 So let's go ahead and try this out. 598 00:31:04,160 --> 00:31:14,690 599 00:31:14,690 --> 00:31:16,500 OK. 600 00:31:16,500 --> 00:31:19,620 It's still stops at down, right? 601 00:31:19,620 --> 00:31:23,970 The other thing, too, is I just realized because we're pausing by delay, 602 00:31:23,970 --> 00:31:25,650 it reverses it, right? 603 00:31:25,650 --> 00:31:28,960 So it starts out really slow, and it gets faster and faster and faster. 604 00:31:28,960 --> 00:31:30,030 And then it stops. 605 00:31:30,030 --> 00:31:34,410 Which doesn't really duplicate how a real arrow would work. 606 00:31:34,410 --> 00:31:37,710 So maybe what we would have to do is do a mathematical calculation 607 00:31:37,710 --> 00:31:39,550 based on delay. 608 00:31:39,550 --> 00:31:43,270 And so what I can do here is, I can take this and I can say, 609 00:31:43,270 --> 00:31:45,810 OK, don't pause delay amount of times. 610 00:31:45,810 --> 00:31:49,250 611 00:31:49,250 --> 00:31:55,780 Let's pause whatever we started at, 500, minus delay. 612 00:31:55,780 --> 00:31:56,710 I'm just guessing. 613 00:31:56,710 --> 00:31:58,286 Let's see if this works. 614 00:31:58,286 --> 00:31:59,410 We'll copy it and paste it. 615 00:31:59,410 --> 00:32:02,350 But, you know, again, part of the fun of programming, 616 00:32:02,350 --> 00:32:05,164 I think, is just being able to think through some of these problems 617 00:32:05,164 --> 00:32:06,580 and just try different things out. 618 00:32:06,580 --> 00:32:09,685 And I think MakeCode makes it really easy to just experiment 619 00:32:09,685 --> 00:32:12,460 and try some of these things out for yourself. 620 00:32:12,460 --> 00:32:18,575 You know, let me just do, as a test, two frames. 621 00:32:18,575 --> 00:32:22,600 622 00:32:22,600 --> 00:32:25,610 And let's just see if this has that effect of slowing it down. 623 00:32:25,610 --> 00:32:28,820 624 00:32:28,820 --> 00:32:30,890 Oh wait, notice where I put the delay. 625 00:32:30,890 --> 00:32:32,205 I put it in the wrong place. 626 00:32:32,205 --> 00:32:34,330 Let's put it inside the while loop, let's try that. 627 00:32:34,330 --> 00:32:38,180 628 00:32:38,180 --> 00:32:39,350 Oh, it slows down. 629 00:32:39,350 --> 00:32:41,460 There we go. 630 00:32:41,460 --> 00:32:44,580 Now one of the things, too, is ideally, you 631 00:32:44,580 --> 00:32:46,380 can also set a variable so that you don't 632 00:32:46,380 --> 00:32:48,270 have this hard coded number of 500. 633 00:32:48,270 --> 00:32:49,680 Like we could set it to max. 634 00:32:49,680 --> 00:32:52,860 We could say, let's create a variable. 635 00:32:52,860 --> 00:32:55,350 Let's call it max. 636 00:32:55,350 --> 00:32:58,440 Or in this case, MakeCode gives you some freebies. 637 00:32:58,440 --> 00:33:00,180 We can rename this. 638 00:33:00,180 --> 00:33:01,647 And we'll just rename that to max. 639 00:33:01,647 --> 00:33:04,230 And one of the cool things about it is, if you rename it here, 640 00:33:04,230 --> 00:33:06,600 if you rename a variable, it refractors all your code, 641 00:33:06,600 --> 00:33:08,470 and it changes everywhere, which is awesome. 642 00:33:08,470 --> 00:33:21,864 So you know what, let's set max to some value like, let's say 400. 643 00:33:21,864 --> 00:33:23,405 And let's implement something random. 644 00:33:23,405 --> 00:33:26,250 645 00:33:26,250 --> 00:33:30,120 And one of the things that I love in MakeCode is, if you go over to math, 646 00:33:30,120 --> 00:33:34,180 and you choose pick random, you'll pick a random number. 647 00:33:34,180 --> 00:33:40,410 So let's say zero to four times 25. 648 00:33:40,410 --> 00:33:44,355 And so that will be either zero or 100. 649 00:33:44,355 --> 00:33:47,100 Well, let's make it times 50. 650 00:33:47,100 --> 00:33:49,564 So we'll say, we'll multiply this times 50. 651 00:33:49,564 --> 00:33:51,480 Now notice what I'm doing is, I'm just pulling 652 00:33:51,480 --> 00:33:53,700 these blocks out of different drawers. 653 00:33:53,700 --> 00:33:56,024 So I'm pulling this out of the math drawer. 654 00:33:56,024 --> 00:33:58,190 We don't want to just say zero to four, because it's 655 00:33:58,190 --> 00:34:02,080 going be like 401, 402, 403, 404, which you're not going to see any difference. 656 00:34:02,080 --> 00:34:03,400 We want big changes. 657 00:34:03,400 --> 00:34:06,120 So that's why we're putting in a multiplier of 50. 658 00:34:06,120 --> 00:34:09,550 We're setting our max to that. 659 00:34:09,550 --> 00:34:11,504 And this can now replace-- 660 00:34:11,504 --> 00:34:15,350 661 00:34:15,350 --> 00:34:17,070 well it's not going to replace it. 662 00:34:17,070 --> 00:34:18,900 What we are going to do is grab max. 663 00:34:18,900 --> 00:34:25,730 Max is going to replace 500. 664 00:34:25,730 --> 00:34:29,449 And similarly we would want to drag it into these other places, too. 665 00:34:29,449 --> 00:34:43,340 So grab max There we go. 666 00:34:43,340 --> 00:34:45,699 And now we should have more randomness, which is great. 667 00:34:45,699 --> 00:34:51,020 668 00:34:51,020 --> 00:34:54,340 The same problem as you've probably seen, will still happen, right? 669 00:34:54,340 --> 00:34:56,710 Because it's still going to end up ultimately, 670 00:34:56,710 --> 00:34:58,960 even though we've got this while loop, it's checking the while loop, 671 00:34:58,960 --> 00:35:02,140 it's got to execute everything in the while loop until it gets to the end. 672 00:35:02,140 --> 00:35:05,080 And the last frame at the end of the while loop is still a down arrow. 673 00:35:05,080 --> 00:35:07,150 So the game is still rigged, folks. 674 00:35:07,150 --> 00:35:10,420 You're still going to always get the down arrow. 675 00:35:10,420 --> 00:35:13,780 So there are some other ideas that you might have for fixing this. 676 00:35:13,780 --> 00:35:16,030 You know, sometimes people are like, well jeez maybe 677 00:35:16,030 --> 00:35:18,850 we need to separate this out or have a separate if statement. 678 00:35:18,850 --> 00:35:22,750 There are if statements in the logic. 679 00:35:22,750 --> 00:35:25,010 You know, check each time. 680 00:35:25,010 --> 00:35:27,610 So before you display each one of these, check 681 00:35:27,610 --> 00:35:29,830 to see if the delay is greater than zero. 682 00:35:29,830 --> 00:35:33,730 And maybe increment it a little bit each time, break it out. 683 00:35:33,730 --> 00:35:36,010 But in the end, the way to solve this problem 684 00:35:36,010 --> 00:35:39,310 is probably going to be breaking it out of the while loop entirely 685 00:35:39,310 --> 00:35:42,670 and using a different kind of structure. 686 00:35:42,670 --> 00:35:46,949 But I'm hoping just to give you a sense for the complexity of how you go 687 00:35:46,949 --> 00:35:48,490 about solving some of these problems. 688 00:35:48,490 --> 00:35:50,290 And we're still in block land here, right? 689 00:35:50,290 --> 00:35:51,170 We're still working with blocks. 690 00:35:51,170 --> 00:35:54,010 If you go over JavaScript, you can actually work in JavaScript. 691 00:35:54,010 --> 00:35:57,190 In fact, some of the things that you start doing is, you'll notice here, 692 00:35:57,190 --> 00:36:01,750 this is where our math random function is. 693 00:36:01,750 --> 00:36:04,900 694 00:36:04,900 --> 00:36:08,050 And this actually makes a call to math library, calls random. 695 00:36:08,050 --> 00:36:11,420 And then you can actually change stuff directly here. 696 00:36:11,420 --> 00:36:14,050 So if I wanted to add plus to that I could basically just do 697 00:36:14,050 --> 00:36:15,760 this add plus one. 698 00:36:15,760 --> 00:36:22,370 And then if you go back to blocks, it actually goes into the math for you 699 00:36:22,370 --> 00:36:24,330 and pulls out the plus and puts it in there. 700 00:36:24,330 --> 00:36:27,779 So this, you can easily go back and forth between JavaScript and blocks. 701 00:36:27,779 --> 00:36:31,070 And at some point in your projects, you may end up wanting to just kind of stay 702 00:36:31,070 --> 00:36:32,240 in JavaScript. 703 00:36:32,240 --> 00:36:33,590 OK. 704 00:36:33,590 --> 00:36:36,320 Let's show you something else. 705 00:36:36,320 --> 00:36:40,230 So some of the things that you can do with input are kind of cool. 706 00:36:40,230 --> 00:36:41,795 So I'm going to start a new project. 707 00:36:41,795 --> 00:36:46,550 708 00:36:46,550 --> 00:36:54,570 And actually, you know what, I'm going to go over to some of these projects 709 00:36:54,570 --> 00:36:56,580 here that are already given to you. 710 00:36:56,580 --> 00:36:58,167 And this is a nice way to learn. 711 00:36:58,167 --> 00:37:00,750 Lots of different projects here and you can see the JavaScript 712 00:37:00,750 --> 00:37:01,458 for all of these. 713 00:37:01,458 --> 00:37:06,174 Some of these I think you'd probably only do in JavaScript. 714 00:37:06,174 --> 00:37:07,590 But a lot of them have the blocks. 715 00:37:07,590 --> 00:37:10,256 Some of the more advanced ones, like infection, which I'm hoping 716 00:37:10,256 --> 00:37:14,280 will have a chance to take a look at, they're done in JavaScript, primarily. 717 00:37:14,280 --> 00:37:17,480 We're going to look at servo calibrator. 718 00:37:17,480 --> 00:37:19,400 And this is what this actually looks like. 719 00:37:19,400 --> 00:37:22,670 And so what I'm going to do is, I'm going to download servo calibrator. 720 00:37:22,670 --> 00:37:27,480 721 00:37:27,480 --> 00:37:33,870 And I'm going to actually move it onto my, I actually have a servo hooked up. 722 00:37:33,870 --> 00:37:41,726 723 00:37:41,726 --> 00:37:44,177 Let's see here. 724 00:37:44,177 --> 00:37:45,510 And the servos are pretty cheap. 725 00:37:45,510 --> 00:37:47,970 You can purchase these, I purchased mine from Amazon, 726 00:37:47,970 --> 00:37:50,040 I think, they were like $3 or $4 each. 727 00:37:50,040 --> 00:37:51,530 They're not expensive. 728 00:37:51,530 --> 00:37:54,420 I actually got a block, I got a whole bunch of servos, 729 00:37:54,420 --> 00:37:55,890 actually for my students. 730 00:37:55,890 --> 00:37:58,440 I got like a whole box of them. 731 00:37:58,440 --> 00:38:02,370 And they're awesome for experimenting with. 732 00:38:02,370 --> 00:38:05,480 733 00:38:05,480 --> 00:38:11,530 So I'm going to actually move this downloaded program onto the micro bit. 734 00:38:11,530 --> 00:38:13,440 Just plug this in. 735 00:38:13,440 --> 00:38:14,370 So it should show up. 736 00:38:14,370 --> 00:38:19,580 737 00:38:19,580 --> 00:38:25,260 And if I go over to downloads, I'm going to grab the micro:bit servo calibrator, 738 00:38:25,260 --> 00:38:27,410 and I'm going to drag it over to micro:bit. 739 00:38:27,410 --> 00:38:32,462 And this copies it on to the actual micro:bit itself. 740 00:38:32,462 --> 00:38:34,420 And you'll notice that on the micro bit, you'll 741 00:38:34,420 --> 00:38:37,580 see a little yellow light that's flashing. 742 00:38:37,580 --> 00:38:39,020 And so we've just copied that on. 743 00:38:39,020 --> 00:38:41,680 744 00:38:41,680 --> 00:38:44,710 And I've got a little servo motor here with a little arrow, 745 00:38:44,710 --> 00:38:46,510 with a little high sign. 746 00:38:46,510 --> 00:38:51,920 And if you press these buttons, you can actually move the servo back and forth, 747 00:38:51,920 --> 00:38:54,481 which is kind of neat. 748 00:38:54,481 --> 00:38:57,230 But what I was thinking of is, I want it to come up with a project 749 00:38:57,230 --> 00:39:03,320 where when you use the rotation sensor on it, so when you turn this thing, 750 00:39:03,320 --> 00:39:09,430 it actually reads it and makes this servo motor react. 751 00:39:09,430 --> 00:39:12,270 So let's try that out. 752 00:39:12,270 --> 00:39:15,440 So what I'm going to do is instead of saying forever 753 00:39:15,440 --> 00:39:19,121 show a number, what I'm going to do is forever. 754 00:39:19,121 --> 00:39:20,870 I'm going to copy some of this stuff here. 755 00:39:20,870 --> 00:39:27,910 So this write pin, write it to angle, I'm going to copy that. 756 00:39:27,910 --> 00:39:29,410 And I'm just going to paste this in. 757 00:39:29,410 --> 00:39:31,117 Pin zero is the servo. 758 00:39:31,117 --> 00:39:33,700 So now what I'm going to do is, I'm going to go over to input, 759 00:39:33,700 --> 00:39:38,600 and I'm going to choose rotation or pitch. 760 00:39:38,600 --> 00:39:43,210 And you'll notice that if you hover over this, this will tell you what it says. 761 00:39:43,210 --> 00:39:45,050 It'll tell you what it does. 762 00:39:45,050 --> 00:39:46,280 It says it's disabled. 763 00:39:46,280 --> 00:39:50,450 Let me plug this in here and maybe it'll, tell me what you do. 764 00:39:50,450 --> 00:39:53,890 This is the pitch, or roll, of the device, or the rotation on the x-axis 765 00:39:53,890 --> 00:39:55,830 or the y-axis in degrees. 766 00:39:55,830 --> 00:40:01,430 So you can change it by choosing this either pitch or roll. 767 00:40:01,430 --> 00:40:02,530 I think. 768 00:40:02,530 --> 00:40:04,100 Yeah, pitch or roll. 769 00:40:04,100 --> 00:40:06,860 So let's go ahead and download this. 770 00:40:06,860 --> 00:40:11,590 771 00:40:11,590 --> 00:40:16,130 And I'll go back, version 5 here. 772 00:40:16,130 --> 00:40:25,130 773 00:40:25,130 --> 00:40:27,410 And I see the yellow light. 774 00:40:27,410 --> 00:40:30,080 It's going over to it. 775 00:40:30,080 --> 00:40:33,500 OK, wow, it's all the way at the end. 776 00:40:33,500 --> 00:40:45,080 So I'm turning it, and I can feel the servo kind of wanting to move. 777 00:40:45,080 --> 00:40:51,810 So I think it's detecting the rotation, but it's not moving. 778 00:40:51,810 --> 00:40:55,440 So for a troubleshooting thing, what are some things that we might want to know? 779 00:40:55,440 --> 00:40:57,499 How do we figure this out? 780 00:40:57,499 --> 00:40:59,040 It's just like a programming problem. 781 00:40:59,040 --> 00:41:01,180 Now it's connected to hardware a little bit, too. 782 00:41:01,180 --> 00:41:03,930 783 00:41:03,930 --> 00:41:07,540 What are some reasons, maybe, why this thing might not 784 00:41:07,540 --> 00:41:10,210 be doing what we want it to do? 785 00:41:10,210 --> 00:41:12,370 It's like humming a little bit. 786 00:41:12,370 --> 00:41:20,500 787 00:41:20,500 --> 00:41:22,500 Might have something to do with the range, yeah. 788 00:41:22,500 --> 00:41:27,530 Do we know what the range is for the servo? 789 00:41:27,530 --> 00:41:31,130 You'll notice here, if you look at this, this basically changes by five. 790 00:41:31,130 --> 00:41:33,230 So max is zero and five. 791 00:41:33,230 --> 00:41:35,220 And it goes to 180. 792 00:41:35,220 --> 00:41:37,020 So maybe it goes from 180 to zero. 793 00:41:37,020 --> 00:41:39,311 But we don't know where zero is in the range of motion, 794 00:41:39,311 --> 00:41:40,700 servo goes back and forth. 795 00:41:40,700 --> 00:41:42,840 Zero could be here, right? 796 00:41:42,840 --> 00:41:45,460 797 00:41:45,460 --> 00:41:47,300 It's 180 degrees of motion, right? 798 00:41:47,300 --> 00:41:49,710 So it could be, zero could be here, going to 180, 799 00:41:49,710 --> 00:41:52,390 and we're all looking at positive numbers. 800 00:41:52,390 --> 00:41:56,410 Or zero could be here, and it could be negative 90, positive 90. 801 00:41:56,410 --> 00:42:00,040 All we know is that it's 180 degrees. 802 00:42:00,040 --> 00:42:02,999 So how might we go about figuring that problem out? 803 00:42:02,999 --> 00:42:04,540 Like how do we know what it's saying? 804 00:42:04,540 --> 00:42:08,350 805 00:42:08,350 --> 00:42:10,360 Let's try this. 806 00:42:10,360 --> 00:42:12,940 We'll go to forever, and we'll put in show number. 807 00:42:12,940 --> 00:42:15,340 But this time, this time instead of showing the angle, 808 00:42:15,340 --> 00:42:19,080 we'll just go ahead and show the rotation. 809 00:42:19,080 --> 00:42:21,840 And so now, whatever the rotation is at, this thing will show us. 810 00:42:21,840 --> 00:42:23,670 And one of the nice things about the simulator, 811 00:42:23,670 --> 00:42:25,461 you don't need a micro:bit to try this out. 812 00:42:25,461 --> 00:42:31,755 You can actually test what this thing is doing by using the simulator itself. 813 00:42:31,755 --> 00:42:42,480 814 00:42:42,480 --> 00:42:46,057 So looks like negative 50, negative 5042-- 815 00:42:46,057 --> 00:42:47,640 wow, that's a whole stream of numbers. 816 00:42:47,640 --> 00:42:52,930 817 00:42:52,930 --> 00:42:54,840 Well let's try it out on the actual thing. 818 00:42:54,840 --> 00:42:57,450 Let me go ahead and send this thing over to the micro:bit, 819 00:42:57,450 --> 00:42:59,283 and we'll actually try it on the real thing. 820 00:42:59,283 --> 00:43:07,330 821 00:43:07,330 --> 00:43:09,430 All right. 822 00:43:09,430 --> 00:43:10,540 Where are you micro:bit? 823 00:43:10,540 --> 00:43:11,050 There it is. 824 00:43:11,050 --> 00:43:14,280 825 00:43:14,280 --> 00:43:15,090 Right down there. 826 00:43:15,090 --> 00:43:19,580 827 00:43:19,580 --> 00:43:24,590 So that little bit of an experiment might help us kind of craft 828 00:43:24,590 --> 00:43:26,820 a different kind of project. 829 00:43:26,820 --> 00:43:36,270 So if we go over to the servo calibrator here. 830 00:43:36,270 --> 00:43:39,390 831 00:43:39,390 --> 00:43:44,690 Let me go over to this one. 832 00:43:44,690 --> 00:43:45,190 OK. 833 00:43:45,190 --> 00:43:49,110 834 00:43:49,110 --> 00:43:52,730 So this one we actually set the angle to 90, and then we write it to, 835 00:43:52,730 --> 00:43:54,470 oops sorry. 836 00:43:54,470 --> 00:44:00,960 So now if we set the rotation, and we add 90 to it, 837 00:44:00,960 --> 00:44:03,210 then we should end up with the right values 838 00:44:03,210 --> 00:44:06,360 here that we've kind of determined experimentally from working with it. 839 00:44:06,360 --> 00:44:07,818 So let me go ahead and download it. 840 00:44:07,818 --> 00:44:17,337 841 00:44:17,337 --> 00:44:18,920 And we'll kind of drag this over here. 842 00:44:18,920 --> 00:44:27,930 843 00:44:27,930 --> 00:44:29,850 And then for this what I'm going to do is, 844 00:44:29,850 --> 00:44:32,700 I'm actually going to detach it from here, because I'm 845 00:44:32,700 --> 00:44:38,590 going to actually use the actual battery packs so that I can hold this mobile. 846 00:44:38,590 --> 00:44:42,194 And you'll notice that now that I've got the rotation, and you were right, 847 00:44:42,194 --> 00:44:44,110 it was the range, it was related to the range. 848 00:44:44,110 --> 00:44:48,995 And when you get the range working, well now I could put this in my hand. 849 00:44:48,995 --> 00:44:52,280 850 00:44:52,280 --> 00:44:53,580 And then get this thing-- 851 00:44:53,580 --> 00:44:55,685 did I just dislodge these things? 852 00:44:55,685 --> 00:44:57,560 I think I just dislodged the crocodile clips. 853 00:44:57,560 --> 00:45:02,740 854 00:45:02,740 --> 00:45:05,330 And get it to move fairly accurately this way. 855 00:45:05,330 --> 00:45:08,277 So now imagine that you had these things separated, 856 00:45:08,277 --> 00:45:10,360 and you had this wired up so the wires are hidden. 857 00:45:10,360 --> 00:45:14,665 You could actually work out some kind of a game where you know, 858 00:45:14,665 --> 00:45:18,670 you could even have something that was wrist-mounted that 859 00:45:18,670 --> 00:45:22,550 telegraphed the motion somewhere else. 860 00:45:22,550 --> 00:45:25,870 So there's just some interesting ideas that that might give you for games. 861 00:45:25,870 --> 00:45:28,780 And this actually, this is a cheap servo motor. 862 00:45:28,780 --> 00:45:31,300 I have some servo motors you can use. 863 00:45:31,300 --> 00:45:34,340 I went to Starbucks and I had a little coffee stirrer, 864 00:45:34,340 --> 00:45:36,340 and I'm using some tape. 865 00:45:36,340 --> 00:45:41,080 So what I love about maker projects is they can be low budget, 866 00:45:41,080 --> 00:45:43,109 and they can be simple, cheap, easy prototypes. 867 00:45:43,109 --> 00:45:46,150 And that's really the best way to learn is just create lots of prototypes 868 00:45:46,150 --> 00:45:46,941 and work with them. 869 00:45:46,941 --> 00:45:50,860 So if you're interested in a project that has some tangible element to it, 870 00:45:50,860 --> 00:45:54,460 that has you actually working with real stuff in addition to doing the coding, 871 00:45:54,460 --> 00:45:57,190 but the coding is really to make the real stuff work, 872 00:45:57,190 --> 00:45:59,840 that's where the micro:bit, I think, can really come in handy. 873 00:45:59,840 --> 00:46:03,610 Now there's one aspect of this that we haven't talked about yet. 874 00:46:03,610 --> 00:46:07,150 This actually has a radio transmitter, communicates via Bluetooth. 875 00:46:07,150 --> 00:46:10,420 And so if you have other micro:bits, you can actually communicate wirelessly. 876 00:46:10,420 --> 00:46:16,030 So I could put this micro:bit somewhere else and have something on this end 877 00:46:16,030 --> 00:46:20,140 that was sending information about the rotation angle as a variable, 878 00:46:20,140 --> 00:46:22,760 invisibly, to another servo. 879 00:46:22,760 --> 00:46:26,050 So you could actually make a motion, or make something happen, 880 00:46:26,050 --> 00:46:29,710 or make lights happen, across the room, using Bluetooth, 881 00:46:29,710 --> 00:46:32,120 using the radio blocks in MakeCode. 882 00:46:32,120 --> 00:46:33,790 And the radio blocks are all right here. 883 00:46:33,790 --> 00:46:36,440 884 00:46:36,440 --> 00:46:37,940 And so just as an example-- 885 00:46:37,940 --> 00:46:48,646 886 00:46:48,646 --> 00:46:51,770 so this was the servo, and we found out what the maximum and minimum values 887 00:46:51,770 --> 00:46:53,540 were for rotation on the x-axis. 888 00:46:53,540 --> 00:46:56,400 889 00:46:56,400 --> 00:46:59,660 But you can create a radio simulation that basically looks like this. 890 00:46:59,660 --> 00:47:02,649 So you would work with different partners, 891 00:47:02,649 --> 00:47:05,190 and these are just some of the radio blocks that you can use. 892 00:47:05,190 --> 00:47:09,750 So radio set group one, what that does is it establishes a group number. 893 00:47:09,750 --> 00:47:15,690 And so any micro:bit that has that group number will be able to communicate with 894 00:47:15,690 --> 00:47:18,910 another micro:bit that has the group, the same group number. 895 00:47:18,910 --> 00:47:24,157 And so I would have you pair up, or pair up by table, or work by table. 896 00:47:24,157 --> 00:47:26,240 And as long as your group all has the same number, 897 00:47:26,240 --> 00:47:28,610 you can communicate with each other, and you won't interfere with other 898 00:47:28,610 --> 00:47:29,600 people's. 899 00:47:29,600 --> 00:47:31,640 So you can decide what this number is. 900 00:47:31,640 --> 00:47:33,620 You can set that ahead of time. 901 00:47:33,620 --> 00:47:37,250 Then when you press a, if you just use radio send string, 902 00:47:37,250 --> 00:47:39,170 you can actually send a string. 903 00:47:39,170 --> 00:47:43,820 So I'm from Hawaii, when we say hello to people, sometimes we say aloha. 904 00:47:43,820 --> 00:47:46,910 And you could send that string, aloha. 905 00:47:46,910 --> 00:47:50,802 When you receive the string on the other end you can show the string. 906 00:47:50,802 --> 00:47:53,010 In other words, remember this is like the say blocks. 907 00:47:53,010 --> 00:47:55,610 So this will actually show the string that it was received. 908 00:47:55,610 --> 00:47:58,220 And if what you received, you can check the value of it, 909 00:47:58,220 --> 00:48:00,710 if it's the same as that string, you can then 910 00:48:00,710 --> 00:48:03,480 send the string mahalo, which means thank you. 911 00:48:03,480 --> 00:48:07,160 So you can try that as a quick little project. 912 00:48:07,160 --> 00:48:13,037 If you have to micro bits is try sending aloha and try receiving mahalo. 913 00:48:13,037 --> 00:48:14,870 And this is a great, this is a fun activity. 914 00:48:14,870 --> 00:48:18,380 My wife, Mary Hyong, who works with sixth grade at Punahou, 915 00:48:18,380 --> 00:48:19,580 she came up with this idea. 916 00:48:19,580 --> 00:48:21,260 She works with her kids with that. 917 00:48:21,260 --> 00:48:23,210 And then she has her students try to come up 918 00:48:23,210 --> 00:48:25,580 with different kinds of scenarios for what kind of data 919 00:48:25,580 --> 00:48:28,040 could you send and receive. 920 00:48:28,040 --> 00:48:31,190 And even for you, I would encourage you to think about, 921 00:48:31,190 --> 00:48:33,380 play around with the micro:bit radio block, 922 00:48:33,380 --> 00:48:35,870 and think about what is it that I can send and receive. 923 00:48:35,870 --> 00:48:37,770 And you wanted to experiment with JavaScript 924 00:48:37,770 --> 00:48:40,520 and start working with some more advanced structures, think about, 925 00:48:40,520 --> 00:48:43,790 we've done a lot of work this semester with storing strings and parsing 926 00:48:43,790 --> 00:48:45,680 strings in different ways. 927 00:48:45,680 --> 00:48:47,900 You have text blocks, that you can work with and make 928 00:48:47,900 --> 00:48:49,610 code, that will parse the strings in different ways, 929 00:48:49,610 --> 00:48:51,900 and conjugate them, and do other kinds of things. 930 00:48:51,900 --> 00:48:55,700 So could you create some kind of a semi-intelligent communicator that 931 00:48:55,700 --> 00:48:59,750 actually either uses or, what if it was something like a sign language 932 00:48:59,750 --> 00:49:02,900 translator, or something that managed to work with a servo 933 00:49:02,900 --> 00:49:07,280 or take the content of a text string, and communicate over to the servo. 934 00:49:07,280 --> 00:49:09,380 For the purposes of this independent project, 935 00:49:09,380 --> 00:49:11,588 you're probably going to want to dive into JavaScript 936 00:49:11,588 --> 00:49:13,910 and start working with some different functions. 937 00:49:13,910 --> 00:49:19,100 You can send and receive, you can return values like tuples and things 938 00:49:19,100 --> 00:49:22,760 like that, using MicroPython, if you wanted to. 939 00:49:22,760 --> 00:49:25,610 So you can actually, you can create struts and enums. 940 00:49:25,610 --> 00:49:28,010 So there's a lot more that you can do with the language, 941 00:49:28,010 --> 00:49:29,140 aside from the blocks. 942 00:49:29,140 --> 00:49:32,270 So if you want to push this further, you could definitely 943 00:49:32,270 --> 00:49:36,137 do a project, that would be a good project, that 944 00:49:36,137 --> 00:49:37,470 would use a lot of these things. 945 00:49:37,470 --> 00:49:38,690 So again, come talk to me. 946 00:49:38,690 --> 00:49:42,460 Let me know if it's something that you're interested in. 947 00:49:42,460 --> 00:49:49,070 Last thing is, there is actually a, this is a really cool activity. 948 00:49:49,070 --> 00:49:51,340 I'm just going to kind of show it. 949 00:49:51,340 --> 00:49:53,650 I don't think we have time to run it as a group today. 950 00:49:53,650 --> 00:49:59,990 But what's really neat about it is, there is a project. 951 00:49:59,990 --> 00:50:03,980 952 00:50:03,980 --> 00:50:05,850 My wife and I actually wrote a curriculum. 953 00:50:05,850 --> 00:50:08,730 It's a Maker curriculum using the micro:bit. 954 00:50:08,730 --> 00:50:15,000 It's free, it's on Microsoft's site, and I've linked to it in the resources. 955 00:50:15,000 --> 00:50:19,440 But one of the programmers over at Microsoft, my buddy Pellee, 956 00:50:19,440 --> 00:50:22,750 he actually created this infection simulation. 957 00:50:22,750 --> 00:50:25,140 And what's really neat is we actually can 958 00:50:25,140 --> 00:50:28,210 use this to talk about how diseases spread in a community. 959 00:50:28,210 --> 00:50:33,150 And so the idea behind it is, everybody has a micro:bit. 960 00:50:33,150 --> 00:50:37,340 And one of the micro:bits, unbeknownst to everybody else, has a virus on it. 961 00:50:37,340 --> 00:50:38,420 And that's patient zero. 962 00:50:38,420 --> 00:50:41,586 And so what will happen is, you can go up and you can meet people by holding 963 00:50:41,586 --> 00:50:44,000 your micro:bit close to somebody. 964 00:50:44,000 --> 00:50:47,300 And when you're close enough, the micro:bits will actually exchange 965 00:50:47,300 --> 00:50:49,920 information, and it's like they've met. 966 00:50:49,920 --> 00:50:53,180 And there is a phase of the game where you go around you meet as many people 967 00:50:53,180 --> 00:50:54,277 as you can. 968 00:50:54,277 --> 00:50:56,360 But the disease actually has an incubation period. 969 00:50:56,360 --> 00:50:59,870 So after a certain amount of time, they're going to start beeping. 970 00:50:59,870 --> 00:51:06,750 And as they start beeping, what you'll notice is, 971 00:51:06,750 --> 00:51:09,150 different people are going to get sick based on the order 972 00:51:09,150 --> 00:51:10,274 that they met other people. 973 00:51:10,274 --> 00:51:13,710 And so it becomes sort of this inference-deduction activity 974 00:51:13,710 --> 00:51:16,806 to try to figure out who got, who is sick first. 975 00:51:16,806 --> 00:51:19,680 And so that's-- and then you can talk about things like quarantining. 976 00:51:19,680 --> 00:51:21,370 So, you know, like some people decide, well, I'm 977 00:51:21,370 --> 00:51:23,430 just going to sit at own table, and I'm not going to meet anybody else. 978 00:51:23,430 --> 00:51:25,114 We're just going to meet ourselves. 979 00:51:25,114 --> 00:51:26,280 And then we'll stay healthy. 980 00:51:26,280 --> 00:51:28,290 And sometimes that works. 981 00:51:28,290 --> 00:51:30,870 One time I did this with a group, and two people decided, 982 00:51:30,870 --> 00:51:32,654 they said don't come near us. 983 00:51:32,654 --> 00:51:35,070 We're going to stay separate, we're not going to get sick. 984 00:51:35,070 --> 00:51:36,480 We're going to let everybody else get sick, 985 00:51:36,480 --> 00:51:38,310 and then we're going to be the last one standing. 986 00:51:38,310 --> 00:51:41,226 And what happened is, after about five minutes, both of them got sick, 987 00:51:41,226 --> 00:51:42,890 and both of them expired. 988 00:51:42,890 --> 00:51:44,640 And the whole rest of the world was saved, 989 00:51:44,640 --> 00:51:48,960 because just as luck would have it, one of them actually was patient zero. 990 00:51:48,960 --> 00:51:52,692 And by deciding to isolate themselves, unknowingly, they 991 00:51:52,692 --> 00:51:54,900 basically quarantined themselves and saved the world. 992 00:51:54,900 --> 00:51:58,400 So lots of different kinds of things you can talk about, 993 00:51:58,400 --> 00:52:01,860 like, within the context of a science class working with this. 994 00:52:01,860 --> 00:52:04,380 But it's a fun, fun activity. 995 00:52:04,380 --> 00:52:10,780 This had to have been done in JavaScript. 996 00:52:10,780 --> 00:52:19,450 So for this, let's see where the code itself is. 997 00:52:19,450 --> 00:52:21,190 Oh here it is. 998 00:52:21,190 --> 00:52:24,020 So again, similarly, you would go to the actual page here. 999 00:52:24,020 --> 00:52:26,450 And you can find this, my link to this. 1000 00:52:26,450 --> 00:52:29,230 You can also go to the micro bit, the micro-- 1001 00:52:29,230 --> 00:52:32,960 the MakeCode website, and you'll see this. 1002 00:52:32,960 --> 00:52:38,950 1003 00:52:38,950 --> 00:52:42,420 But if you, you know again, I love the micro:bit, 1004 00:52:42,420 --> 00:52:45,550 and I love MakeCode because it makes it so easy to get into the programming 1005 00:52:45,550 --> 00:52:46,050 of it. 1006 00:52:46,050 --> 00:52:50,730 But I don't want you to, I think it's misleading how simple it is. 1007 00:52:50,730 --> 00:52:53,880 You can actually get involved at a level of complexity 1008 00:52:53,880 --> 00:52:56,847 with this that is, you know, pretty advanced. 1009 00:52:56,847 --> 00:52:58,680 And there's so much that you can do with it. 1010 00:52:58,680 --> 00:53:01,260 It's such a, JavaScript is powerful language. 1011 00:53:01,260 --> 00:53:04,710 And micro:bit is a great little platform, 1012 00:53:04,710 --> 00:53:07,262 so you can do quite a lot with it. 1013 00:53:07,262 --> 00:53:08,970 And you can really, I would encourage you 1014 00:53:08,970 --> 00:53:10,594 to push the hardware as far as you can. 1015 00:53:10,594 --> 00:53:12,300 Learn as much as you can about it. 1016 00:53:12,300 --> 00:53:15,150 And think about what kind of activity can I 1017 00:53:15,150 --> 00:53:20,070 come up with that uses either tangible materials, 1018 00:53:20,070 --> 00:53:22,750 or involves other people working with it? 1019 00:53:22,750 --> 00:53:26,250 And then definitely share out what you do, 1020 00:53:26,250 --> 00:53:31,710 because there's a growing community of micro:bit enthusiasts, 1021 00:53:31,710 --> 00:53:35,340 lot of, I've got a lot of friends on the MakeCode team who are working really 1022 00:53:35,340 --> 00:53:36,390 hard on this. 1023 00:53:36,390 --> 00:53:39,060 But they're really curious to see what are some other things 1024 00:53:39,060 --> 00:53:40,450 that people come up with. 1025 00:53:40,450 --> 00:53:44,790 And so if you have questions or if you need resources, you know, 1026 00:53:44,790 --> 00:53:49,640 I'll certainly see what I can do to help support you on that. 1027 00:53:49,640 --> 00:53:53,840 So with that, I'm going to officially wrap up and thank you 1028 00:53:53,840 --> 00:53:57,044 for coming to this seminar and for being here. 1029 00:53:57,044 --> 00:53:59,210 But I'll stay around at the end to answer questions. 1030 00:53:59,210 --> 00:54:02,070 And if you want to play around with some of the servos and things like that, 1031 00:54:02,070 --> 00:54:03,278 certainly feel free to do so. 1032 00:54:03,278 --> 00:54:04,910 So again, thank you so much. 1033 00:54:04,910 --> 00:54:07,910 And I'm looking forward to seeing all of you around campus. 1034 00:54:07,910 --> 00:54:10,060 Thanks a lot. 1035 00:54:10,060 --> 00:54:10,932