Now it is time to import a complex program and to learn from it.

To access the full video please subscribe to FLLCasts.com
- #831
- 09 Apr 2018
TL:DR.
Copy the contents of the material ledPulseDemo.py;
type
nano ledPulseDemo.py;
right click to paste;
press Ctrl+O, then Enter, then Ctrl+X;
type
python ledPulseDemo.py
and follow the on-screen instruction.
Create the demonstration program
The program ledPulseDemo.py could be already in the folder Perfect_Programs, but could be also missing. Do you remember how to ask the command line for long list of files and directories in a folder?
We will assume the program is not already there and we will create it together.
Open the ledPulseDemo.py from the material here and select all the text. Then copy it.
Nano text editor
The simplest text editor in a command line interface that we know is called Nano (as in nano-technology, a small thing).
With the command nano you can open files and read and write in them.
Type
nano ledPulseDemo.py
and this command will open an editor for the file ledPulseDemo.py. If the file is already there, you will see its contents (use TAB or even double TAB while typing to check if something exists). If the file does not exist, the editor will be blank, empty and you can create the file.
Now that you have a blank nano editor opened, do a simple right mouse click (on Windows) and that will paste your earlier copy into the nano editor.
To save your creation in nano you must press Control key and O (as in output). A question about the filename appears in the bottom of the screen. It asks about the filename and the name ledPulseDemo.py is already filled, and the choise Yes is highlighted.
So simply press Enter.
Now in order to close the editor press Control key and X (as in Exit).
Start the program
You are smart people, figure out on your own how to ask python to start the program that we just created.
Open the program and read each and every line of it
Now open nano once again and this time read all the program and figure out what acomplishes each line of code. After that it is going to be your turn to create code.
Python demo program to blink and pulse LED
Part of the Perfect STEM course, you should have a Raspberry Pi and an LED connected on GPIO 18 for this example to work.
Courses and lessons with this Tutorial
This Tutorial is used in the following courses and lessons

Perfect STEM course. Module 1 - Smart Car with Raspberry PI
Disassemble a remote control car. Change the brain of the car with a smart computer like Raspberry Pi. Build a smart device with artificial intelligence that you could control from your phone and that could freely navigate itself in the real world and on the Internet. Use your hands. Develop programs for your robot and your phone. Be curious and invent.
The perfect course lives up to its name. You move through the content, we check it and return feedback to you.
In the end, you should be able to better understand how to program and design smart devices that would make the world a better place. For everybody age 12+, 16+, 21+, 35+, etc. The hardware costs about 150$. It changes through the years so it might take some time for you to find it as Raspberry PI, motor drivers, power banks and h-bridges.. they change. Note that the course was designed to be led by a teacher with a decent knowledge in embedded hardware and software. This, on the other hand should not stop you, if you are curious.
- 118
- 42:47
- 136