The mpyEditor is what you use to write your mpy program and program the microcontroller. It is software app that needs to be downloaded and installed onto your computer. See installation instructions Install
Start the mpyEditor software
The top part of the mpyEditor is where you write your mpy program, the bottom part is where you program the microcontroller and where you see program output messages. The mpyEditor is based on the Editra editor, it has lots of fancy features which you can use if you want, but it is not needed, there are more details on the mpyEditor and Editra here.
If it looks a little different to this then you may need to reconfigure the window so that all the mpy features are enabled. Visit here to reconfigure the mpyEditor.
Choosing a mpy file you want to work on
All mpy files have filenames which end with .mpy
If you want to use an existing mpy program, you open it from the File menu on the main toolbar at the top of the window, select File -> Open… and then select the folder where the file is stored, and select the file to be opened and then click on the Open button. The file will then open as a new tab in the mpyEditor Notice that the tab at the top shows the name of the file.
You can open multiple files within the editor, each one will open up with a new tab with an X next to it. You can switch from one file to another just by clicking on the tab to select it, the selected file is the file that will be programmed into the Launchpad. Clicking on the X will close the tab.
Quite often when starting a new project it is easier to start with existing mpy file from a similar project, and modify it for your project, that way you have a good starting point to make changes specific to what you want to do. When you do this, open the file and then save it away with a new filename. This way you leave the original file unchanged. To save the file with a new filename select File -> Save As… and then select the folder where you want to save your file and type in a new filename. Then click the Save button. Notice that the filename at the top the tab will change also to show that you are editing the new filename.
Write your program
This is where you need to get creative and write the commands to make your microcontroller interact with the outside world, and make it come to life!
It’s usually a good idea to choose one of the example programs as a starting point for your new program. Choose one that does something similar to what you want to do. Here are some tips to help you along:
- You will need to plan out your project, decide which IO pins you are going to use to connect to switches, LEDs and motors, etc.
- Make sure you have read the Getting Started pages as that will give you a basic overview of the mpy language, and there is help on all the mpy commands.
- Remember that spaces are important! Make sure you dont have a spaces at the beginning of a line, unless is part of a code block.
- Don’t forget to put useful comments into your code, this will really help you when you try to do something fancy.
- Start small and work your way up to the full project. Its more fun if you write a few lines of code and then program that into the microcontoller and test it out, than add a few more lines to your program and test that out. This way you are building up your program one step at a time and are more likely to get it working.
Connect the Launchpad
So you have your program ready. Next we need to connect up the Launchpad to the computer.
make sure that correct MSP430 Microcontroller chip is plugged into the Launchpad. There are different MSP430 microcontrollers chips and they
- First step then is to plug in the Launchpad board into your computer using the USB cable. After you have plugged it in you should see the Launchpad status change from ‘Not Connected’ or ‘Searching’ to ‘COMxx: MSP430Gyyyy’ in green . This tells you that the mpyEditor is talking to the Launchpad and the microcontroller has been detected. The xx in the COMxx is the computer port number, this is a number that the computer assigns to the Launchpad in order to communicate with it. The yyyy in the MSP430Gyyyy is the MSP430 chip number that has been detected in the Launchpad board. If you do not see this see here for help getting the connection working correctly.
When you have written your mpy program, plug the Launchpad USB cable into the computer. After a few seconds the mpyEditor will show that the Launchpad microcontroller is connected. Then press the PROG button, it will then start to flash (literally), indicating that the program is being compiled and it will also be flashed into the microcontroller chip. Messages appear in the mpy console window showing that the microcontroller was successfully programmed or not.
- Download and Install
- Starting the mpyEditor
- The different parts of the mpyEditor
- Programming the Launchpad
- Errors and debugging mpy programs
The mpyEditor is known as an IDE (Integrated Development Environment) because it is used to write the program and also to compile and run the program, all from within the same tool.
The mpyEditor is built on top of the Editra editor. Editra is a general purpose editor that can be used for for writing text files or creating programs in many different languages. The mpyEditor part of it is a plug-in.