PicoMite: Running BASIC on a Raspberry Pi Pico

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] welcome to another video from explaining explainingcomputers.com this time we're going to be setting up and experimenting with a picomite which is a raspberry pi pico running a version of the basic programming language specifically a pico might runs mm basic which was written by jeff graham for the micro mite microcontrollers and maximite computers so let's go and take a closer look right here we have a raspberry pi pico which unlike other raspberry pi models at the time of making this video was in stock at major pie retailers including adafruit pimeroni and the pie hut the pico is a microcontroller rather than a general purpose computer like other raspberry pies and has a recommended price of four dollars or three pound sixty this said i paid six pounds for this picot because it's got pre-soldered headers as we can see under here and this will allow me to plug it straight into a breadboard here specifically i'm going to be using this monk makes breadboard for the raspberry pi pico where if we take the picot and plug it in at this end it goes in down there like that and push that down here hopefully it'll go in there we are and as you can hopefully see the great thing about this particular breadboard is it's got all the connections for the pico actually labeled on each particular rail oh and we're also going to need a micro usb to usb type a cable to connect the pico to a computer it'll plug in down here now just in case you're not aware a pico is based on raspberry pi's rp2040 microcontroller chip which contains the dual core arm cortex m0 plus cpu clocked at up to 133 megahertz together with 264 kilobytes of ram and 2 megabytes of onboard flash storage the job of a pico is to control other electronic components and the board is normally programmed using micro python or c plus plus or similar modern languages however here we're going to be using mm basic simply because i think that running basic on a picot is a very cool and interesting thing to do so here we now are on the jeff's projects website from jeff graham very interesting website if you're into electronics and computing and things like that but here we're going to limit our attention to this section over here basic on the raspberry pi pico where as you can see there are two links and the second link is for setting up a pico might vga where you run basic on a raspberry pi pico connected to a vga monitor and the ps2 keyboard i might try that in a future video requires a bit of wiring up but for now we're going to stick to basic interpreter and here as with every other page on this website everything is very very well documented i really like this website you can spend ages just reading this site it's it's really interesting anyway to set up our pico might we'll scroll down to the bottom to find the downloads where we want this download here the pico mic firmware and also a manual so i'll click on download and this would download a zip file as you can see i've already downloaded it so i won't waste jeff's bandwidth by downloading it again so i'll cancel on that and we'll go to the the folder with the zip file in and we'll extract the zip file like that yes windows that'll be fine there we are it's finished and as you can see there's various files here one is the manual let's just open that up this manual is brilliant 170 page manual with all sorts of stuff in it this is really really good teaches you how to use the thing all the commands are documented fantastic documentation but what we want to do is to copy this file across to our raspberry pi pico to set it up as a pico might so to do this we need to go across to the pico and to hold down its boot select button and then to plug it in to the pc and back on our windows desktop we can see it's mapped to pico as a drive it's down here as drive f so if we take the uf2 file here for pico might and we copy that file like that and we open up drive f and we paste it in like that and this will set up our pico might and there we are it's copied and if we now look across to the picot its little led is flashing indicating everything has been set up okay so what we now want to do is to communicate with the pico might and to do that we need to first of all find out where it is connected to our computer and here in windows we do that by going to this pc and right clicking and going to manage like that and then we'll go down to device manager and we'll go down to ports common lpt there and we can see we've got a usb serial device which has to be here the pico might on com3 if you've got lots of non-standard usb devices plugged into your computer things that aren't mice and keyboards and storage and stuff like that you might have to check what's there before you plugged into pico to find out exactly what port it's on but here it's clearly on com3 so to access the pico might we now need a terminal program and here i'm going to use putty which can be freely downloaded from putty.org so let's run it up there we go and we now need to configure things to connect to the pico and the first thing we need to do is to go here to select the connection type to be serial and as you can see it's defaulted to com1 we know we want to use com3 we just look at up so we'll do that and we'll set the speed here to be a 3 8 400. this is fantastic classic computing isn't it and we now need to go to keyboard where we need to set the backspace key to be control h like that and then i'm going to go now to appearance and to change the console font which you don't have to do but i'm going to do this so things will read better here on video so i'm going to change this to console as bold 26 which is going to be nice and clear to use in this video so we'll do that like that and okay next what you do have to do is to go down to a serial down here to make sure all this is set correctly it's already got comp 3 38 400 at the speed there it needs data bits 8 stop bits 1 parity none but also flow control needs to be set to none like that and we can now click on open to open up the pico might but before i do that i'm going to go back to the top and i'm going to give a name here i'm going to call these settings pico might seems a good name and click on save so next time we want to connect to the pico we can just select the settings and load them in anyway we don't need to do that now it's all set up so we can now just click on open very exciting and there we are and we'll maximize this window like that and now all we have to do is to press the magic button which is the enter key on the keyboard i'll do that and there we are we now have a command prompt in mm basic and to test it's working we'll type the classic basic command which is a print hello like that and uh it works isn't that marvellous let's try as well printer i know 674 divided by 87 and all that's right as well marvelous and as a final test there is a command called memory here in and then basically if we enter that there we are we can see all the available storage on our picomyte all waiting to be used for exciting stuff greetings here i am back again we're now going to do some pico might basic programming but just before we start i'm going to enter this command and what this will do is to change the size of our console so it is 16 characters deep and 64 across and i'm doing this because the default of 24 by 80 is too big to use with the font size i've selected so i'll enter like that nothing will apparently happen but when we go to create a program by typing edit like this as you can see at the bottom of the screen we have a menu this will not have fitted on other not change the side of the console so let's now write a basic program and in mm basic we can choose whether or not we want to use line numbers but i'm going to use them just for nostalgia's sake here i think so i'm going to start by doing 10 for a equals 1 two five and then we'll do a 20 print mr mr scissors i think and we'll do a 30 next hey there we are a nice classic basic program and we'll save by pressing f1 there we are and to run the program we type guess what run like that and there we are the program's worked it's printed mr scissors five times and it's worth noting that on a pico might programs are written directly to flash memory so if you turn off the raspberry pi pico boot up into mm basic again your program will be exactly as you left it this said you might want to work with lots of different programs how could we do that well we could save the program and to save a program it's a good idea to first give it a name we don't have to but it's a good idea so let's do that by doing edit to get back into our program and we add a program name by putting it in a comment right at the start so we'll do that we have a single quote and we'll call this uh mr scissors like that i think i'm going to get rid of my line numbers now i've had my nostalgia will work without them for now on but i just thought i'd show you they do work if you want them so we'll do that like that there we are and we'll press f2 this time to save and run just to show you it still works it still does but we can now save the program by typing flash save and 1 and this will save the program into the first flash memory slot and to prove that if we type flash list like that there it is our first program is there called mr scissors but what if we wanted a second program well i could do edit to get back into the program let's change it to be something different there we are and if we save and run this f2 obviously it has changed we can now do a flash save and two to put that into slot two and if we do a flash and a list like that you can see we now have two saved programs and obviously right now if i do run it will run the stanley program if i do run it'll print stanley rules five times but if i do a flash and a load one and i now do a run it'll print mr scissors because of course if we now go into edit we're now working on the mr scissors program rather than the stanley program and it's worth noting that whilst here we're saving to flash memory slots if you have a micro sd card reader connected to your raspberry pi pico and then basic can also save to microsd card right i've now hooked up three leds with current limiting resistors to the pico and if we look at this wiring diagram we can see exactly what's going on i've got each of gp 13 14 and 15 wired to a current limited resistor a 220 ohm current limiting resistor which then goes to an led and through to the ground rail and we go across to the console here i've written a piece of code to make use of this it is called running led with a comment at the top and then as you can see i'm setting gp 13 14 and 15 to be digital outputs and one of the great things about the pico is you can set all of the general purpose gp pins to be digital output analog output digital imports analog inputs pwm etc after that i've defined a variable called speed to be 1000 which is going to be 1 000 milliseconds when i use this in the timing of a loop and then after that i've defined label a after which we're setting gp13 to be one that'll turn on the first led we're then pausing for the value of speed we're then turning off the first led turning on the second pausing again same for the third and then finally at the end we're going to go to label a to create an infinite loop so we keep cycling through the leds and i would point out there were two ways you could write this code in them and basic you can do it as i've done here using a label or the code could be like this with line numbers and where the final command could be go to 60 to take us back to the start of our loop but i think it's better not doing that i think it's better not using line numbers and using a label so let's bring in a shot of the board and run the code like that and as we can see yes we've got our little running led it's a little bit slow isn't it so let's just uh stop it which we can do by pressing ctrl c to break into our infinite loop like that if we go back to edit let's change the speed we've got a variable for it let's change it to say 300 milliseconds like that and the save and run again oh that's a bit better isn't it we've now got a running led going at a higher speed now the final thing i want to point out here is that at the moment we've got the pico running connected through to a computer which we're using to program it down this cable but the pico mod is designed like any micro controller to function entirely independently and so what i'm going to do is to go back to the code and we will just stop things again and if i do a flash list you'll see i've saved the program in slot 3. and if i now enter the command option auto run three like that what that will do is to auto run the program in stock three when the picot boots so what i'm going to do here is to come out of this we'll close this terminal down there we are and if we go back to the board i'm going to disconnect it from the computer it's actually connected by this extension cable so i'll un-connect that obviously the light's gone out and here i've got a power bank so we can power it independently by this battery let's just turn that on and if i now plug in the power bank like that it'll hopefully take not too long the thing will first of all boot up there it is and yes it is running the program so we've now got the pico the picomite running independently executing some basic code right just when you thought it couldn't get any more exciting it has because i've wired in this push switch between gp12 and the 3.3 volt rail and if we go across to our code i've changed this a bit into another program called switch demo and this starts out by setting pin gp12 to be a digital input and then after that and importantly it's got the argument pull down and what this does is to turn on an internal pull-down resistor in the picot so that the input is not floating around when the switch isn't pressed it's either pulled down to the ground rail through the internal pull down resistor or it'll be taken up to 3.3 volts when we push the switch other than that things haven't changed very much we set the other things up as previously we've still got our loop but inside our loop i've added in this command here if pin gp 12 equals one of the words if the switch is pressed we're going to go to label b and guess what happens at label b let's have a look at label b we're going to turn on all the leds wait for three seconds and go back to label a i just had to think of something to demonstrate the working of the switch so let's again run the code like that and as we can see our led is in its little running light configuration but if i press the switch oh look all the leds come on stay there for three seconds and then we go back to our little led running light i'll do it again i could play with this all day there we are that's very exciting and it should go back to the other thing as it was previously so there we are we've added in a switch and made it work in mm basic now as is hopefully becoming clear mn basic is an excellent implementation of the beginner's all-purpose symbolic instruction code and in its pico might incarnation takes full advantage of the capabilities of the raspberry pi pico opportunities include control and readout of all kinds of devices and sensors and mm basic on the pico can even control an lcd display which i may come back to in a future video if i covered it here this video would never end but the final thing i do want to mention here is that if you want to try out mm basic and you haven't got a pico you don't want to pico jeff graham has made a version available for dos or windows as we can see on his website here and it's available from the link down here as you can see and if you download the files as we did previously you end up with a couple of files here the first time you run mm-basic windows objects to it you have to say yes it's okay which i think it is but let's just load in file things here work slightly differently to the pico because we don't have things like memory slots you can just load from a drive and there we are the file is in so we can edit i can run the thing there we go so as you can see if you want to experiment with mm basic all you need is a windows pc four decades ago i took my own first practical steps in computing writing programs in basic on this a sinclair zx81 and 40 years later i've very much enjoyed being reacquainted with the basic programming language on the picomyte and i'd like to thank jeff graham and his colleagues for making the pico mite a reality but now that's it for another video if you've enjoyed what you've seen here please press that like button if you haven't subscribed please subscribe and i hope to talk to you again very soon [Music] you
Info
Channel: ExplainingComputers
Views: 112,155
Rating: undefined out of 5
Keywords: Raspberry Pi Pico, MMBasic, MM Basic, Geoff Graham, PicoMite, Pico Mite, Raspberry Pi Pico BASIC, BASIC, Christopher Barnatt, Barnatt, Raspberry Pi, microcontroller
Id: Cxmjy1nz6MM
Channel Id: undefined
Length: 19min 29sec (1169 seconds)
Published: Sun May 01 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.