 And welcome, it's me, John Park. And this is John Park's workshop. We have arrived. It's time. Let's do it. Just checking my audio and it's working. It seems like it's working. Let me know if you hear otherwise. So welcome, everyone, over in Discord. Thanks for coming by for the chat. If you want to join the chat in Discord, just head to adafruit.it slash Discord and you'll get an instant invite to the server where loads and loads of people are hanging out and chatting and we've got a bunch of different channels there where you can get help on different projects, different products, different programming languages. There's all kinds of good stuff going on there, lots of good real-time action. So head on over there and check that out. Let's see. What are we going to do? Let's get started with a little housekeeping, some little things I like to mention at the beginning of the show. You probably know what's coming up next. Check it out. This is the Adafruit Job Board. If you want to hire someone, if you want to get hired and you're a maker, an engineer, developer, then head right here. This is the Jobs Board. It's at jobs.adafruit.com. It's totally free. You'll see here we've got some highlighted positions up at the top. This is in the Jobs Help Wanted section. Look, there's an enrollment director at Blue Stamp Engineering position in San Francisco. There's also an iPhone or rather ESP32 phone app expert anywhere in New York. Interesting. So go check those out if you're looking for work. That's the Adafruit Jobs Board. It's totally free. It's totally great. Yeah? I think we can all agree on that. Let's see. Next up, I do a show on Tuesdays. You may be aware of it. It's the JP's product pick of the week show. It looks like that or something sort of like that. It's bonkers, but I have fun doing it. And this week, the product pick was this really cool little UV sensor, an ambient light sensor. This little piece right here, I built it onto a sort of demo board there with a big battery and a display and all that and a Pico driving it. But if you want to see a little recap, then I'll show you one. Here it is. The product pick of the week this week is the LTR390. It is a UV and ambient light sensor. This is really useful for determining if it's safe to be outside in the sun for human skin. This is a little UV LED and I'm getting a read of about 14, 15, 16. I'm going to run right out my workshop real quick and hold this up to the sunlight. I think we've got direct sun right now. There's no clouds. 126. Count of 95 is one index level on the UV index. That should be a UV index 1.3. That is my product pick of the week. It's the LTR390 and it is a UV and ambient light sensor breakout board in STEM-A-Q-T format. Now, we don't need to watch that a second time. Sorry about that. I forgot to uncheck the default loop thing, so it'll just play over and over again. I'll tell you one of the things that if you're not familiar with it, one of the things that's made life a lot easier for prototyping and hooking up your different boards to different breakouts and sensors has been the advent of this STEM-A-Q-T format. Here's an example of one right here. You can see this is a breakout board that's got these little JST four pin connectors. It's based on the SparkFunQuick format, QWIC, I think. We call it the STEM-A-Q-T format, differentiate it from the STEM-A format, which can be three pin. It can also be four pin I squared C. STEM-A-Q-T is always I squared C, and now you don't necessarily have to solder on header pins and put your board on a breadboard to then connect it up to a microcontroller. We can now plug things together with the little STEM-A-Q-T cables. Here's one right here. That's one of the longer ones. We sell a bunch of different cables. In fact, I think that's one of the cool new, let me head to my web browser here for a second and show you, pop this up here in the, you can go to what's new, if you click the what's new at the top of Adafruit, you'll see that one of the what's news is this JSTSH four pin STEM-A-Q-T quick cables in various lengths. Some of the items in the Adafruit store have enough variations on them that we create one of these product category pages. Here you can see all the different variations on the STEM-A-Q-T cables as well as the adapter cables that go between STEM-A-Q-T and STEM-A or the JSTPH and JSTSH and even ones that break it out into some socket headers and socket pins. So we have a bunch of different variations on that, but I can go to this page and like Lady Aida said, we sell a ton of these, so we get them in. We sell them almost as fast as we get them in. So if you're looking for some, you can head to the page and if it's out of stock right now, like this 100 millimeter cable, you can click on the notify me, put your email address in there and hit notify me and then you'll be able to get a, get a jump on things when it comes out. I've found these to be great. So if you're not familiar with STEM-A and STEM-A-Q-T, go check them out. We've got a lot of info on those and a bunch of different boards. And that's what I tend to focus on on my new product pick show. So come back on Tuesday, it's coming Tuesday at this same time, one o'clock PM Pacific, four o'clock PM Eastern time, and I will have another pick, another product pick for you. All right. By the way, new little mini segment, JP's fashion picks. I'm wearing a shirt from Winter Bloom. My favorite, it's kind of washing out there in the light, one of my favorite synthesizer companies with our own friend of Adafruit Thea at the Star Girl flowers at the at the helm there. And I was just given this shirt recently as a gift by my daughter. So I'm excited about the Winter Bloom logo shirt. So in case you're wondering, that's what I'm wearing, even have a little Winter Bloom pin on. I'm all Winter Bloomed out today. All right. Let's see. Next up, what's going to happen here? This seems like a really good time to do a make code minute. So check it. All right. Let me get some things set up here that I do. Let me put on my glasses so I can actually see what I'm looking at there. Ah, geez. There we go. Yeah. Oh, thanks, FX music. FX music says nice shirt indeed. I appreciate it. All right. So what I wanted to show for the make code minute today is a new extension inside make code arcade that's called the text sprite extension. If you've ever made make code arcade games, you have probably A, had a lot of fun, B, learned a bunch of things and C, wondered if there was an easier way to deal with text. There are a few existing methods to do things like pop up bits of conversation or ask the player a question. But now there's a much more general use extension called the text sprite extension. Here you can see, I'm going to go large screen on my simulator. You can see I have a little banner here that says text sprite, but check it out. I can actually control this thing with my cursor and I can have it react to things like the position on screen. So when I get to the top of the screen, boom, I have it changing to the word top and I've added a little icon to the side of it. And then text sprite down at the bottom. You can see it's exists in Z space. So I've put it over the background but under my character here. And the way this works is, first of all, you'll head to advanced, go to extensions and add the text sprite extension. And then you can see here I've got some new blocks such as set text sprite to a text sprite type of object with some default text. That's a variable I made. And you can specify the color and if it's on top of a background color, you can do things like set the size of the font, the position on screen, border colors. And then you can treat it like a regular sprite so I can move it with buttons. You can have it collide with things. You can have it stay in screen. And you'll also see right here in my forever loop what I'm doing is I'm checking the sprite position of the text sprite and then I have the text changing when I reach different places on the screen. So that's just a quick example of what you could do. Oh yeah, one more thing here I've got. If I press the A button, it changes to we have text and if I hit the B button, text sprite. So really cool, really exciting. This will make a lot of different things inside of your games way easier to do than ever before. So way to go, make code team, very excited about that. And so that is how you can create text sprites inside of your games and make code arcade. And that is your make code minute. Whoops, thank you. Yep, I was muted. All right. So the next thing I want to do was go over a make code arcade game pick of the week. And this is one that I found inside of the forum, forum.makecode.com in the arcade channel there. There's the audio alert. We have some delays. Thank you. I appreciate it everyone. Letting me know. Keeping me honest there. Ah. Two out of three times I forget that. Yes. All right. I'm going to wait for the stream to catch up because there's a lot of helpful mentions in the comments about my audio being off. Thank you. All right. I think we're good. Yeah. All right. So my make code arcade game pick of the week here is called join us for a bite by JT Machinima or JT Music. The creator of this is unsigned Arduino and what this is is a really impressive bit of music inside of an arcade game, inside of a make code arcade game. And let me play it for you and then we'll talk about it a little bit. So I'm going to hit this link. This is a song from Five Nights at Freddy's and I'm going to try to turn on my music. Hopefully I won't get an echo. All right. So let me, let me pause that there. You can tell this is really sophisticated and complex for a song inside of make code arcade. And as you may have guessed, this was not created one block at a time using the music blocks, the play note blocks. It's actually, it only exists in JavaScript. You won't see blocks for this one. As you scroll through this, you will ask the question like I did. There's no way that someone hand typed this in. So there must be some kind of a parser going on. So I asked the question in the make code arcade forum. And the author unsigned Arduino said the answer here was actually in a different forum post. This is how I make songs in arcade. First to find some sheet music and download it. Then I open it up in Muse score software, make song adjustments if necessary and export it to MIDI. And then unsigned Arduino created some Python scripts that will convert the MIDI file into a JSON file. And then finally the JSON is run through another script to produce the type script file, which is what the JavaScript inside of make code arcade looks like. So that's how we arrive at this. Some people in the forums have asked if the author would maybe upload those files so that people can do it. But I thought that was really great and really impressive. And you can get polyphony, I think there's probably four note, five note polyphony going on there. Notes playing at the same time. Very cool. And a very catchy song from Five Nights at Freddy video game. So very cool. Nicely done. If you want to check that out, head to the arcade forum, forum.makecode.com and check out Join Us for a Bite by JT Machinima created by unsigned Arduino. So thanks for sharing that. And that is the make code arcade game pick of the week. All right. Let's see. My sound is off, says Charles Burnett Ford. Do you mean off like it's out of sync or do you mean off like it's not playing? Oh, that was four minutes ago. So that was probably when it was off. I think we're good now. Yeah. All right. Let's see. What's next? So last week I showed the sort of beginning planning process for doing a little bit of a modular robotics demo with Pico microcontrollers. This is the RP2040 Pico from Raspberry Pi. And in the past, we've done demos with things like the Fundamentals series inside of Cricket that Ann Barela created. So we have learned guides that show you little snippets of how do I use a DC motor? How do I use a stepper motor? How do I trigger a solenoid? How do I use a servo motor? And so these are fundamental things that people really often want to do one or two of, mix and match, maybe add buttons or dials or some smarts or sensors to it. And so, yeah, Todd Bott and the chat ass modular. Oh, that kind of modular. Yes, it's not modular synthesizers, but little modules, little fundamental bits of code that you'll be able to grab and use and change if you want that'll show you how as well as some simple diagrams, some schematics for the wiring. So that's what I started talking about last week. So I've put this together. This is my demo board here that you can see in the in the other camera view here. And what I'll do, let me see, if I can give you a bit of an overhead view as well and that front view, I can go through the demos here. I showed some of this on show and tell last night. And then I've updated it since then. So I had it initially just running through all of its demos on restart. But now what I've got is this little blue button will allow me to trigger each one in series. So I'm just going to restart. So I've got this red button here that's my restart. And now if you watch over here and listen, this is a five volt solenoid. So when I press the blue button, that's the first demo. It's going to click that a few times. OK, so it clicks it four times. Next demo, it's going to go and turn this servo motor to some angles, 090, 0180. And then I also have a move by one degree, more of a sweep test on the same servo. You can go from 0 to 180. And then I'm going to spin this little DC motor here. I'm going to go forward at half speed, backward at half speed, forward at full speed and backward at full speed. And then the last thing I'll do is run this stepper motor. So this is a very nice, smooth, quiet stepper motor. I'm just going to revolve it twice in each direction. Let's see a couple of full revolutions there. And then it'll go the other direction, nice and smooth. And what I'll do is actually, let me switch camera views. Actually, I don't have my setup there, so I'm going to come around here. I'm going to switch camera views and I'll show you what that wiring looks like. And I'll be building a learn guide on this, including some nice fritzing diagrams so that you can see how it's built. And let's go to a full screen here and a window there. And I'm going to lay this on its back. Right now it doesn't actually lay down too neatly because I haven't put a little frame around it. And I have a couple of these arcade buttons poking out the back. So I'm going to set it like so. And let me prop that up right there so it doesn't crush itself. There we go. So let me dial this in a little bit closer here to the breadboards and focus that in. I found, by the way, autofocus gets tripped out by a lot of these high contrast markings like grid lines and these points on the breadboards. I'm just using a manual focus there. So you can see what's going on here. I've got a, let me move this a little bit. I've got a five volt source coming in. And I'm using that to drive pretty much everything here. And then I'm using USB to power the Pico. Let me see if I can zoom in any closer first on, there we go, there we go. So on the Pico here, let me grab something to point with that you can see. So the Pico here is running out to the power rails on the spread board from its three volt source because there's some three volt logic used on some of these drivers. And of course, going to ground, the first one I'll talk about here is the stepper. So this is a little stepper breakout that we have. It's the DRV8833 and it is connected to the stepper motor here. There's essentially two sets of coils for the even stepping and this is able to drive it in both directions. I think it's a dual H bridge there. This is getting essentially four pins coming off of the Pico, are telling the board what to do when we send it in different directions. But we're using a motor driver library that I'll show you to make the coding easy on that. And then you can see also I'm getting my five volt source directly from the DC and then it's being shared to some other things. If we look over down here, I've got a H bridge motor driver that is just accepting two PWM pins from the Pico. And then it's sending out to the DC motor and that's getting power from the five volt rail and going to ground up here. And that's able to reverse, since it's a H bridge, it's able to reverse that current so it can go forward and backwards and we can control the speed with the PWM. The servo motor is this connection here and that's actually just direct. We could have plugged it closer onto the board here but this made it a little neater for the wiring. And so again, the servo just has a PWM data pin coming from the Pico. And then last board here over off on the side. And this is what I mean by module. I didn't want to cram everything on one breadboard. So I've tried to spread it out here a little more. So here I have a MOSFET transistor with a protection diode. And that is allowing me to send, use a pin on the Pico to either, it's a digital pin. So it just turns it on and off. And that allows the current to flow or not to this solenoid here. Let me reset this here and we'll see if this works. Sometimes the solenoid, I think the solenoid is actually a little greedier than five volts. Five volts from this is straight up five volts. Usually I've run these off of a battery pack, which is more like six volts. And so it doesn't want to run so well when it's horizontal. Oops, sorry, I'm not letting you see that guy there. Let me put that into view. So let me reset and press that blue button again. So this is less happy at five volts. So I'm actually cheating right now and I'm giving it six volts off of a bench top power supply. But I'm going to see if I can get that working better with just the single supply. Or we'll feed it more and handle the extra voltage for some of these that don't want it. So that's the basic assembly. Now let me, I'll give you the close up tour of the action if I can keep the wires happy. So let me put this, I'll unplug that servo power just because I don't have enough cord. Okay, so here we'll do the next demo, which is going to be this servo motor. And then I'll press that blue button again and we'll get the smooth step, I thought. Oh, have I shaken something loose? No, I just didn't press the button. And now we can check out that DC motor. So it's half speed, half speed reverse, full speed, full speed reverse. And then lastly, the super smooth stepper. And this I've just, I've mounted this all onto a doubled up thickness of some foam core board. You can do all kinds of different things with how you, how you connect stuff. I'm not suggesting this is necessarily the way you're going to build this unless you were doing maybe a science fair demo, but more of a suggestion of how to get the code and the wiring together. C Grover says you might need a big capacitor local to the solenoid. I was wondering about that. FX Music asks, this is all in Python or Circuit Python, right? Yeah, so this is all in Circuit Python. So let me, with that segue, thank you, FX Music, let me jump into the code here. So you can see, let me switch over to Adam. And you know what, let me make this bigger and put myself off to the side here. I'll make it bigger still. Doesn't need to be that wide, but I'm going to try to zoom in here. So you can see it a little better. Okay, so first of all, with this connected, let me hook up to the serial output. If we're still connected, oh, I lose it when I hit reset, I forgot, that's right. Okay, so here, this will at least give you some little bits of feedback at the bottom there. So first thing I'll do is import some libraries, including time, board, which gives me the board definition of the Pico, as well as a number of different digital IO library sections. I'm importing PWM IO, and this is important because Pulse IO doesn't work on the Pico. But we have an alternative, which is the PWM IO. And then I'm also importing from Adfrute Motor, the stepper motor and servo drivers. I'm also creating a little LED object for the onboard LED that's built onto the Pico. So that blinks for me a couple of times whenever I press the button, so I know that it's aware and responding. And I set up a little function for blinking so I can call that easily. I have a button that I'm setting up as an input so that I can press that blue button to create different modes to go through the different modes. Then we set up the solenoid. So solenoid is just a simple digital output, digital pin output. And I'm also setting up just a default strike time and recovery time, so this is a latching solenoid. So it can push out and stay out, pull back and stay back. And so I'm giving it a little bit of time in each position. And that's how we get that sort of even sounding, clicking sound. Then I have a little solenoid test. And so what I did was while I was working on this, I created these functions so that I could test them out immediately. So here I'll just set this solenoid test to click four times. I'll hit save and you should hear it. I unplugged, hold on, I unplugged power on that guy. Let me plug that back in, sorry. And there, sorry, I know you've not seen what I did there, but that's my bench power supply. All right, so I'll resave this, okay, so you can hear it click there. And I just found that very helpful while I was working on this to not have to press the button or go through all the possible demos while I'm working. Let me see, can I give you a small view of, sure, let's not that one, that one, and I'm just gonna move that camera view so you can see that board a little bit better. That'll work, okay. So then in the code, next thing I do, I'm gonna comment this out so it doesn't do it every time. I'm setting up my servo. So I'm creating a PWM pin on the Pico. And by the way, interesting thing I found out is if you look at your Pico, if you look at a Pico pin out, so there's one of my Picos where I've put the pin labeling on there, you'll see a bunch of these listed as PWM pins. I think there are eight channels of PWM and each channel has two pins on it. However, you can't use both of the pins on one channel at the same time, or you run into some issues. So I actually had to use one pin from one channel and one pin for another channel when I was working with the, which one is it? With the motor driver. So this servo just uses a single pin, but if you use a pair of them, they have to be in different channels. So here I'm setting up GPIO zero. So it's the kind of first pin on the board. I'm using that as a servo driving pin. And then I'm using the servo library to make this easy. There's a question about the duty cycle. So the duty cycle is how much it is on. So a duty cycle of two to the 15th power is actually on half the time, and so that's sort of half speed. The full speed value is like 65,535, so that's two to the 16th power. And if you look at what I'm gonna do is actually in the guide, I'm gonna point to our different breakout guides that we have for things like servo where this is explained in a little more detail. And then depending on the servo motor, you'll have a minimum pulse, which is the sort of zero degree location and a maximum pulse width, which is the 180 degree. And so that I've tuned here and I've set my minimum to 500 and my maximum to 2,200. So that's something that can vary per servo brand and even per servo. So it's something that I tuned there. And then I do a little test. So I just set, since our library makes it easy, I don't have to turn on the PWM for a while and then turn off. Instead, I can just use the servo angle setting to go to these different locations, 90, 0, 90, and 180. Here's a better answer to that question from C Grover, duty cycles. The ratio of time when a signal is at its maximum versus the PWM frequencies, period, it's usually expressed as a percentage, yeah. So this is a 50% duty cycle. Then we set up the smooth test. So the first one just goes directly to those angles. It's that typical servo. If I turn that on and you watch the little pink arrow that I put on there and hit save, watch that thing, it's going to jump from location to location. Let me just move this window a little bit for you. So I'll hit save. So that's the servo jumping to its positions as quickly as it possibly can. This next demo instead is a smooth step. So it goes by increments and I've set it to one degree steps. So when I run this one, you'll see it's going to smoothly go. I didn't uncomment the test, run that test function. And that's quite smooth. I think the camera might be making a little jump here than it is. Then I set up the DC motor. So again, this is actually, even though I'm going through that H bridge motor driver chip, it's driven with PWM. And PWM to back up a little bit is a way to sort of approximate analog signals. Because what we want to be able to do is send sort of smoothish signals of percentages of power to send to this. And we do that by turning it on very rapidly, which is what this pulse width modulation is. It's a square wave that's either really dense or spread out. And that approximates or averages into smooth analog like curves. So again, I'm picking two PWM pins that are not on the same PWM channel here. I had that problem at first and I saw an error. There's some GitHub issues about that where people are realizing this on the Pico the way it's set up. And then for a test, I'm just using our motor libraries throttle setting, which is just a neater way of expressing, just like angle. This is a throttle is a neater way of expressing a PWM duty cycle. So 50% or close to 100%. For some reason, I found it wasn't working at one. So I set it to 0.9. You could go to 0.999 at work. So if I, you can see here it's just very simple brute force of coding here. It's just setting it to a throttle value, setting the time to sleep for a little bit, setting it to off, which sort of disengages the motor. And then setting it to a different value. So if I comment this test and hit save, you can watch that orange wheel. It's gonna go through that same little test there. And then we set up the stepper motor. This is the last one. So here, again, this is some very specific stuff to setting a stepper motor. You'll see in our stepper motor guide this motor I'm using has 513 steps in it. That's how the coil of it is wound. And it can go at different rates. I've found here the fastest that seems nice is 004. And 01 is smooth after that. It gets steppy because it's sort of ticking between turning the coils on and off and getting to the next little step. The digital IO pins, there's four of them used here that nothing special about them. They can be any four. I happen to pick four that were in a row. And those are driving that stepper driver board. We set this up. We tell it which coils. I'm not using micro steps. I'm finding it works best in just the one step style, not double steps or anything like that. And so when I run this, I've set up a couple functions that just run through those 513 steps and it turns on one coil than the next. So it's just alternating, turning the coils on, which pulls it around in a circle. And then we can also set that stepper direction to backwards. My test for that just invokes both of those twice, which is why it loops around two times. So if I uncomment that, let me make sure I comment to the DC motor I did. So if I run this now, you'll see off in the side there, that little purple piece of foam, hook, claw thing, and that'll go backwards. And again, I just have some simple little readouts there in the serial monitor. And then the last thing I did here was set up a function for going through the different modes with a button press. So this is just a function that says it's gonna be fed 0, 1, 2, 3, or 4. And depending on which of those it's fed, it will run one of those test functions up above. And then the main loop of the program is this right here. All it does is watch for button presses. If the button gets pressed, I blink my little on-board LED a couple times. I go to the next mode and I'm using that modulo to loop 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4 with each button press. I print out which test is being done. I have a big debounce, 0.8 seconds just so I won't hold the button too long and have it double tap it. And then I run the test function. So let me see, I turned off the stepper test, yes. So if we save it now, you can watch that output. And I'll go over here and press that button again. So on the first press, get the solenoid. Then second press, servo motor, direct angles. Third press, smooth servo. I miss that one all the time, there we go. You can also see here is the little power LED on the Pico is going to blink when I press it, double blink. Now we get motor test. And last one is this little smooth guy here, full times. Whoops, drag a cable across the room with me. So that is my little demo board. Like I said, I'll be putting together a guide so that you can use that to figure out different little pieces parts of what you want to put together. I think that's going to do it. Did I miss anything? No, I think we've done it. So thanks all for coming out. Thanks everyone in the chat for saying hi, and also reminding me when I forget my microphone is off. And let me know in the chat if you have any other sort of similar demo board things you'd like to see on here. This is modular, like I said. It's something we can add to. I want to make these fairly discreet so you can just chunk off something. Hugo says in the comments, is it near? Does that last one look a bit like a sloth claw asking for lars? Yeah, I just can't comment on that. Oh, hey, Steve. Steve is here. Steve just joined the chat. Hi, Steve. Nice to see you. Steve's busy ordering lots and lots of key switches, I think, for his MIDI keyboard project, OMX27. Hey, Jim. All right, thanks everyone. I will be hanging around. Again, thank you for the Suggestion C Grover, maybe adding a capacitor to my solenoid to see if I can get that working on five volts again. It works, but only when the thing is straight up and down. All right, and that's going to do it. So oh, relay. Yeah, so Hugo mentioned maybe having a relay on there would be cool. That reminds me also we have electromagnets in the store. So yeah, there's definitely a few things. Eventually, maybe we'll get sound added to this, potentiometer read, some things like that. I think rotary encoders are on the way. They're not there yet, but for Circuit Python running on Pico, we will have rotary encoders at some point. Could do neopixels more with lights, some displays. So we'll see how this gets built out. I'd love to build it into something nicer, like a wood display or something a little more permanent than foam core, but that's going to do it. All right, thanks, everyone. I will see you next time for Adafruit Industries. I'm John Park. This has been John Park's Workshop. Bye-bye.