Let's get your first lesson going

This page will take you to all the steps necessary to create your first program and execute it.  For all other lessons, you can simply repeat these steps.  This page is the companion for Page 8 of the PodPi magazine edition #1.

Questions?  If you have questions and if something is not clear, send us a note using this form


Open a Command Prompt

Open a Command Prompt

10. Open a Command Prompt window. 

This will be the screen you use to type the various commands to launch your editor and execute your program.  The commands you type in this window are actual commands sent to your computer only.  They are not the JavaScript program lines of code found in the lessons.  The JavaScript code needs to be saved into a file instead (see step 11).

Find more information about the Command Prompt on the Microsoft help.


Launch your editor

Launch your editor

11. Launch your editor

In order to execute your programs, you have to create a file, save it and then tell Node.JS to execute it.  First you need to launch the editor that you will use to write the program.  You can use any editor of your choice, but for this exercise let's use Notepad - it is simple to use.  In your Command Prompt window, simply type:

notepad led.js <enter>

"nodepad" will call the editor and pass it the name of your program, in this case "led.js".  The <enter> is simply the "enter" or "return" key on your keyboard.

To create different programs, simply name your file with a different name.  For example, rgb.js or light_sensing.js.


Write your code in the editor

Write your code in the editor

12. Write your code

Now that you have the editor open, write the JavaScript code that you find on the lessons, or code that you are experimenting with.

Make sure to respect the format of the code (spacing, upper/lower case, notations, etc.).  The code will fail to execute if you have any typos, wrong characters, etc.

You can find the first lesson on page 11 of the magazine edition #1.  Simply type the code located in the middle of the page.


Save your file

Save your file

13. Save your file

Congratulations!  You have written your code, now it is time to save your file to make sure your computer retains it as you exit your editor.

You do not have to close your editor.  Simply click Save (or press CTRL-S) and your file will be saved.  Next, go to the command prompt to execute it.

If you want to create a different version, you can simply click "Save as...", then give it a different name with the .js extension.  You may need to select "All file types" in the drop-down below the name field.


Execute your program

Execute your program

14. Execute your program

This is the exciting moment you've been working hard to achieve.  Executing your program and discovering what it does!

To execute your program, simply type the following command:

node led.js <enter>

"node" is the command that launches your local JavaScript run-time.  "led.js" is the name of the program you want to execute.  If you have renamed your program or have a different program you want to execute, simply change the name led.js to your program name and press the "enter" or "return" key.


15. Stop the program

Now it's time to stop your program and make changes to it.  Simply press "CTRL-C" twice.  You may also have to press the "enter" key afterward (only on some version of Windows).  This should return you to the command prompt and be ready for the next command.

You can now go to your next lesson and repeat the steps from 11 onward.

and remember to have fun!