Thonny Tips - Using the Debugger

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Ohio gozaima says my Japanese friends would say or here we say good morning for today's video we're going to take another look at the Thani editor and another feature of it and that is uh how we can use the debug features now if you've been working primarily or exclusively with your Raspberry Pi Pico you'll notice that on your run menu the debug functions are pretty much all grayed out non-functional however there is a trick to it now of course I'm going to show you how I work with it when when needed I got to make sure okay yes I'm on that's maybe not right okay I'm in micro python on the Raspberry Pi that's connected this guy and uh I'm going to open Raspberry Pi Pico and my plot sign program that I'm using and several of these other presentations now uh if I look here I can run the program but none of these are functional now I will say that no matter how I go about this these aren't really functional because you're not going to be able to go into the menu when you're running so it's easier just to memorize uh the F7 key f8 F6 Etc the shortcuts just work better than the menu but how do we get this to work well if we're working on a small section of code that we don't need the Pico for where we're trying to figure out maybe an algorithm or something of that nature we can just bring it into Sony as simply a program and run it in in funny within the Python 3 interpreter so that's what we're going to do here so I'm going to close this one and I've got a copy of this program on the computer so I'm going to go into this computer there's the exact same program here you can see it's on the computer not in the Pico we'll open that and it pops up now you'll see that okay it still doesn't care where we got it from but I still don't have this I'm going to go down here now if you work with multiple Picos uh I'm fine you'll notice that almost everyone gets assigned a new com port number I think I'm up to about 27 or something like that but if you click on that you can go to local python3 all right and then depending on how you configured Sonny and The Interpreter uh settings uh that'll be the version of python that it's using now if we go to our run manual you'll notice that we've got debug current script and uh a nicer one and a faster one which one you use is up to you um oftentimes I'm just using it to slow down the iteration of while Loops or other types of loops and so I can monitor data a little more controlled rather than trying to read print statements that are scrolling across the bottom of the screen so we will select uh available do both of them just so you get an idea what you're going to see um right now we are uh stepping through uh line by line and almost word by word within the code and you'll see how I'm hitting the F7 key on my keyboard and now we're seeing how all these things are moving along and this allows you to go slow and you could of course have print statements we'll see that here in a second let me get to there print all that that shows up down below this gives you a controlled way to see data but I can make it a little bit better yet um now at some point if I just want to let it fly I can click up here hit the resume button and the program just runs freely let's do one more cool little thing I want to see what's in the variables as the program is running and I just got to find my my button it's in view variables see that right there that'll bring up a window over here where we're going to see what's in those variables as we do this so again I am going to say run this time I'm going to say faster I don't need to see every word I just need to see every line execute so as I do that notice over here on uh the variables section we're seeing some stuff happening a degree is one of my variables it's at zero radius is at one angle in radians now we'll get through this Loop iteration a few times and you're going to see these very values changing so you can monitor your variables very easily as you're debugging your program this is an extremely handy uh capability but it does require you to run it in a python on the computer not within the Pico but oftentimes when you're doing this you really focus more on an algorithm that's dealing with mathematics and not necessarily inputs and outputs so if you haven't used this in the past give it a try I found it to be very handy in some of my more complex programs by just breaking out that section of code putting it into the regular editor and running it locally and monitoring all the variables hope this helps you on future projects I'm Chris Day Hut for making stuff with Chris Day HUD good to see you here again and I look forward to seeing you in the next video
Info
Channel: Making Stuff with Chris DeHut
Views: 3,728
Rating: undefined out of 5
Keywords: Thonny, Thonny debug, thonny debugger, Raspberry Pi Pico, RP Pico, Microcontroller, Electronics, Electronic components, Python, Micro Python, Interface, Real world computing, Maker, Making, Chris DeHut
Id: EMAye6AlHFc
Channel Id: undefined
Length: 6min 26sec (386 seconds)
Published: Tue Mar 28 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.