 Hello, I'm maker Melissa. I am sponsored by Adafruit to work on circuit python and other projects And today I'm going to be doing my very first live stream and for this one I'm going to be building a little robotics project. Let me go ahead and share my other camera here And what I have is I'm building one of these little cars There's little cars here with a clue and it's the ringbot car so what I want to start by doing is Assembling the ringbot car just to show you how that goes together Over here make sure I'm in the Chat in case anybody has any questions Okay So let's go ahead and start by seeing what is in this It has just a bunch of little packages including some servos the wheels the body and it has a couple boards here it also includes a screwdriver and Little manual and I'm going to go ahead and set this stuff aside here, and I'm going to be using Actually, I'm going to use this screwdriver here just because I can build a little faster since it has a bigger handle so the first thing to do is to start out with Taking stuff out of the packages now with these bags. We will need Just the tiny screws that attach into the servo itself We won't need the servo horns or the mounting screws and we're going to go ahead and open this one And it includes a bunch of screws already in here, which is why we don't need those other screws So we're going to start out by building These servos into these and what we want to make sure is that the front of the servo is towards The front of the car here And we're going to go ahead and mount screws into the underside here. Oh, that's the wrong screw Okay, and then we're going to do the same thing on the other side, but we're going to kind of mirror it and then on this You look at the wheels they kind of go in on one side and they're flat on the other we want to put the flat side towards The servo itself and then we'll use one of these Little screws that came with the servo We're going to do the same thing on this side. Then we're going to take one side of this Oh, actually we're going to go ahead and install this little wheel with these little rivets And found it easiest just to start by inserting it In here and then sliding this in sideways Move that mouse out of the way And then these are a little tricky because you don't want to push down on them until they're in place And then when you just push on them, you kind of pop through and it holds it in place Let's go ahead and install the all the pieces along here So this piece goes here This flat piece goes here And these pieces are all symmetrical so it doesn't really matter which Way that you insert it and open this package up here And I'm going to go ahead and attach this And the switch should be towards the bottom of the car here So it goes like that and I'm going to go ahead and make sure the Wires are just kind of going through here for the moment. This is probably the trickiest part of the build okay Make sure every one of these tabs is in and then the next thing we use is this little Thing has a screw in the end And we just go ahead and insert it through here And insert this side here And that's it So the car is mostly built now I'm going to move this and we're going to open up This side now I've already gone ahead and Programmed This clue but now is actually a really good time if you're building this yourself to do it because The reset button will be up against this board But even if it is mounted you can still use like a little Flathead screwdriver like this and kind of get it in there and push the button a couple times So I found it easiest to go ahead And start with the screws on the ends here and Here I'll take a look at some of these Yes, in case anyone missed it. I am actually putting together a little robotic car like this and then I'll give you a demonstration in just a second And I will go over the code That is on here. Okay, so it just takes five screws there then You want to make sure the wires are kind of routed behind this bar We can go ahead and install some batteries in this I think the little switch is on by default. So I'm going to just turn it off for the moment Oh, that's interesting This is missing a spring. It looks like So I guess I won't be able to demonstrate this particular car um Well, I'll just go ahead and show you for assembling it So you want to install this wire which went underneath there Here and you want to match the The zero v and g you want to match the black to the ground and then on this one you want to plug in the two servos mounted here and If it's backwards in the code you can either switch it in the code easily or You can just swap out the plugs because what'll happen is that it'll actually go the wrong direction when you go to run it But you go ahead and take this you can take this little clear rubber band And bound up these wires Let's see if I had the spring fall out in here or something Now it's just missing all together. That's odd well This one came with two rubber bands too Well, I'll show you with one of these cars here because I know that's all working and So when I'm going to pull this little thing off So when you turn it on It goes ahead and initializes I have it running circuit python 8 right now And then I'm going to go ahead and just show you this iPad here because I have it running eta fruit blue fruit connect And I'm going to go ahead and connect to it. Oh, you can't really see where you're all the glare Let's see if I can tilt it a little Okay, so we're going to go to controller And we're going to go to the control pad And if I press up it starts going forward. I have one set as stop And you can go backwards And you can also turn on the spot Or the other direction Or if you're going forward you can kind of turn as you're going And then stop it And then I have four Set for turning on the little lights here If you want to show little headlights and then I just have two and three changing the undergo color um You can also go to the Color picker here and if you want to go to a custom one You can send the it and it'll Set it to something that looks similar to this, but I think it's off a little bit Or we can go more white if we wanted to or red Whatever you want to do And then if you go back to the control pad You can drive it and you'll notice it changes colors as it's driving, but it'll go back to the custom color that you set and So I'm going to go ahead and go over the code next here So I'm going to plug This again Share my editor. Oh there. That's what I'm looking for Um, so here is the editor. Let me go ahead and shrink this window a little bit so you can see it better So the code.py is just really it initializes it um It goes ahead and it imports board and neopixel and a custom class that I wrote called uh robot here And let me go ahead and Change this around a little bit here. Oh, perfect. Um And then I have it defining the different connections for the of ring bot buggy or ring bit buggy here or ring bit car depending on what um, you want to call it and That way you can go ahead and change the connections really easily in the software if you want to um, I have it initializing the neopixel class. It only has uh, two neopixels underneath it Oh, you can't see because I turned off the camera It has uh, just two neopixels here So I'm only initializing the two of them and the um Then it initializes the robot with just the hardware specific to the little car And in the while loop it just waits for a connection and once it's connected It'll just kind of check the packets and process them So we'll go over to the robot class and I'm going to go ahead and take a look at discord here uh, let's see uh, some uh dj devon 3s Is the robot class part of an available library and I'm going to um With this one. It's actually a custom one that I wrote. Uh, I'm planning on writing a guide here And I can go ahead and attach it there, but um at the moment it's I have it available. Um, I'm a github account and I can share that soon um But I don't think it has the very latest changes. So I want to push that up before I post a link to that Um, it'll eventually be part of the aida fruit loom guide repo Uh, so let's go over the robot class here. So it just grabs in a bunch of different modules Including the pwmi oh here the It does a bunch of the display i o related classes Uh for being able to display like text on here or um some of the vector graphics that I added As you notice the little arrows as it was um turning I just used vector i o for that So there's actually no separate images on this Different on this class here But that would be a fairly easy change to me Um It includes a lot of the different uh definitions from the blue fruit connect service here Uh for the different types of packets and It looks like I have some duplicate code in here that I don't know why it's in there, but we can go ahead and remove some of this Okay That was a little extraneous And of course, I have a little label here for just being able to show the wait for connection So then I have some definitions here for the throttle directions and speeds and That way you can go we can set it to go different color Different amounts up to 1.0 being full speed and negative one being full reverse speed And then I just have a few of the different colors for convenience of programming this And then the initialization We just are basically initializing the left and right motor which has a little Class here and The the reason I have the class method on these ones is because it allows me to make This method part of the class without actually making use of the word self keyword in here and Because these ones actually could be could sit as functions outside of the class itself, but I wanted to include them um So all this does is it creates a pwmio class and then passes that over to the The eight of fruit motor uh continuous servo one because that's what these are and I just have some Max and min pulses. I could probably make those properties. So they're easier to adjust like up here and Then we go ahead and initialize the display which This is it just does anything display related for like setting the background color um I have it creating the Oh, yeah, that's just creating the Rectangle for a background instead of using like a bitmap And then I go ahead and I add it to the display group And then the init bl e stuff is just setting up like the bl e radio the uart service and Just all the initialization stuff you need to do in order to use it And then I have it going through and Setting up a few variables including uh, the little headlights one, which is what I decided to call it setting the initial color to purple and then I'm making sure in case it's running for whatever reason it'll stop it. That's why I have it doing the set speed And let's go ahead and jump down here. Oh, this make palette class was just a little convenient function for Being able to create a one color palette and just returning it because I use that in a number of places So the wait for connection method uh, what that'll do is it starts by setting the status led which is just the little Neopixel on the back of the clue here And it's it's that's the blue and then it starts advertising so that the Adafruit connect program will Be able to see the Clue and then it just kind of waits until it Is connected and once it's connected it'll stop showing that it's available it'll set it to green and Again, I'm setting the throttle to stop. The reason I'm doing that is it will actually update the icon on here as well I have a little convenience Function for is connected. That's back in code. It can check if it's connected here and Then I have a couple functions called set under glow and get under glow And what that will do is this will set the color of the neopixels down here But i'm also making use of the neopixel class to store the color value So i'm just grabbing it from there for getting the current color I wanted to use as few variables as possible and then the status led is just the one in the back of here The toggle headlights will just kind of go turn on and off this and it just Again makes use of the existing Value variable in the digital io class So that way not having to store it in addition to that Um, I have a set left throttle and a right throttle and since they're mounted 180 degrees to each other I have to actually multiply The speed by negative one so that they're kind of both turning the wheel in the forward or the reverse direction Now the rotate right What that will do is It will Well, first of all, let me start with the release color. What that means is It'll set the color of these when you release the um button so like when you're turning left or right and then So then while you're holding it, it'll set the under glow to yellow and true just means Um You know, I actually don't remember what that means. We'll get to that Or no, it's up here. So Oh Save release color that just means it'll kind of set that as its new color Oh, okay. No, it'll still get the current under glow and it'll save but that's what it will be And then We're going we're using these if Um, let me span this a little bit We're using these style here just to make its own instead of it being four lines It's just one line and what this does is it'll run this Function if the cell if the current direction is stopped. Otherwise, it'll turn it right and we do something similar for the speed and Then we set the left and right throttle. This allows me to Use the same function in order to Um Either wrote or spin around in a here. Let me go ahead and demonstrate here. Let me share the camera Again Let's just do this Okay, okay. I'm going to reconnect with the Program Okay, so what this function will actually allow me to do is it allowed me to Use the same function both for spinning it while it stopped And also doing a kind of a half turn while it's going Back to this And then I just have one for the rotate left and rotate right. I probably could have combined these at some point. Um But it was easier just to have it separate So then I have the set throttle what this does is it'll depending on what speed that you're giving it if it's Forward it'll set the little icon to a forward icon Or reverse icon if you're going backwards or stopped if you're stopped And then I have a set speed as a separate function so that I can call it without changing the icon on there And then just sets everything to whatever speed you want And then the stop function Here will basically call The set throttle with a stop and it'll actually show the red Underglow for just about half of a second here and then it'll go back to whatever color it was The check for packets is Again called over In the main function here and this just sends it just checks to see if there's something Waiting and if there is then it'll process it and we'll get to that a little bit later The handle color packet will just i'm just telling it. Um, if it's a color type packet we're going to just set the underglow to it and remove shapes is just a function To the okay. I'm sorry Remove shapes will just kind of remove everything except for the first Object on in the display IO group and that just makes it really easy just to clear whatever is on the screen I just made some convenience functions called add center direct So you can just give it a width and a height or an offset If you need to or change the color this will these functions are kind of like the basis for Uh drawing these shapes here. I just did a centered polygon and a centered circle as well and Actually, I'm going to show you something kind of cool that I did Uh, so I had it figuring out that kind of the dimensions of the shape And it just kind of uses a min and a max function here It uses the lambda item item and what this does is it says Give me the largest value of the first Part of the point because it's kind of a list Well, I'll show you it's kind of a list of coordinates So it just tells me like the largest of this this this this and this one here and I do the same thing with the other ones and then I do minimum ones as well and It provides a nice compact way of determining Where the center of the polygon is similar for the circle here and then The waiting one all it does is it it just draws a label here and says waiting for connection and then the reverse one it clears the screen and It draws a couple polygons to make it with a arrow that appears to be Kind of going backwards. I had to play with that just a little bit same with the forwards and then I have right left and Rotate counterclockwise rotate clockwise these ones I just basically drew a big black circle Well yellow circle in the middle of it And then a rectangle to kind of split it into like two half circles or like two half donut shapes and then I have these just adding little arrowheads to that and then it looks like it's a rotating circle And So the stop one is just a big square. It was easy Um, okay, so we're now at the handle button Press packet. We're actually almost done with going through the code here And all I'm doing is I'm just telling it for whichever of the buttons I'm doing I'm running these different functions here. So it makes it really easy to switch around what you wanted to do This one allows me to Handle the button release packet whereas this is the press packet And this allows me to kind of steer the left and the right while it's going forward without Without losing the speed or the direction And The process package just checks for the kind of packet it is and then sends it to the appropriate function And that is it for the code Let me go ahead and save it with those things removed Let's see. We're about out of time. Well, no, we have a little bit more time. Um Does anybody have any questions you can ask in discord or Even on YouTube because I can see the comments for that as well Um, and I'd like to answer that. Let's see So I will so I do have a couple things to say just add your questions if you have them Um, so if you wanted to expand this, there's actually a lot of different options for expanding it uh, first of all, this has the stemma qt port up here and That allows for adding all sorts of different sensors But there's also a lot built into the clue here One of the things that I wanted to add was uh a little Playing sound but I just ran out of time for adding that because there's a little speaker built in But it also has a microphone. It has a button if you want to change modes. I didn't add that at all It has a color slash distance sensor. It has nine degree of freedom For the motion so I can kind of check any of the orientations that it wants so it could react to that way and Oh, let me bring up my list of Oh, yeah, that's that's pretty much it Um, and then you get like I said, you can add stuff with the stemma qt port There is kind of a built-in a little port for combining with the robot but I I think what they use is that for programming the thing it only allows for really a digital io and some power and you can't use the LEDs at the same time, but you would just move the little switch over and I'm going to go ahead and push Uh these changes really quick to get out this this won't take very long so first of all, I'll grab the changes off the robot paste them to replace that and then I'm just going to go ahead and Okay, now I have the latest changes and I will post where the github repository is that I have it's just on my Personal one at the moment, but it will be moved to the a different one eventually and there it is And that just that includes all the changes. I just made with removing some of the duplicate code Let's see here. Take a look at the comments. See if I missed anything not seeing anything I missed. Um, I'll thank you um so this This was originally designed for the mic the bbc micro bit and The bbc micro bit v2 could work because it also has bluetooth But it is missing the screen. It has like 25 leds and a five by five grid and it um Does not have the stemmy qt port and I'm not sure it has the color distance sensor, but it has a bunch of other things It would be a capable board for sure And it's able to run circuit python as well Um But it's also really difficult to get at the moment too. So the Clue board would be definitely my recommendation for this and The code of course would need to be modified in order to use that um I think that is it unless there's any other questions I see somebody typing on discord at the moment So dj debon vry says the nrf 52 840 has some of the best bluetooth support But it looks like the s3 is in development For it. I think um I'm not sure how well it works uh It definitely could it could work. Yeah, uh, because like the esp 32 has the Both the ble and the classic bluetooth, but I think the s3 is just going to be for the Uh bluetooth ble Um, which is kind of the newer bluetooth and that's actually what this uses So that that could be a possible option, but this was actually designed for more this form factor here Uh, so it works really well Um, there is another option available in the aid of fruit store and there's like this little bot here Which could also take the clue and it's actually really easy to insert it but It has this uh sonar sensor on it and you can actually remove that and just plug in whatever and Be able to make use of i2c that um That's an option if you're using like the micro bit v2 without the stemic ut And this has a couple little uh rgb leds. So I think it would be a different library for that um, but this one is a another little option and See Oh Charles b says you have an extra copy of the digital i o import uh I have digital i o and display i o I'm not seeing it I mean they're very similar and they're the same length of text here, but um Yeah, it's probably just uh display. I was what you're seeing Anyway, uh, thank you for watching and let me go ahead and Swap this out here uh, thanks for watching and joining me and uh Stay tuned for lots of other circuit python day festivities and I think coming up next uh in Uh, about 20 minutes is this doing a special special circuit python themed show and tale and Uh, that should be fun Thanks