Tuesday, July 26, 2016

Getting Started in the Arduino Software (IDE)

Writing Sketches
Programs written using Arduino Software (IDE) are called sketchesThese sketches are written in the text editor and are saved with the file extension .ino. The editor has features for cutting/pasting and for searching/replacing text. The message area gives feedback while saving and exporting and also displays errors. The console displays text output by the Arduino Software (IDE), including complete error messages and other information. The bottom right-hand corner of the window displays the configured board and serial port. The toolbar buttons allow you to verify and upload programs, create, open, and save sketches, and open the serial monitor. 

Note: Versions of the Arduino Software (IDE) prior to 1.0 saved sketches with the extension .pde. It is possible to open these files with version 1.0, you will be prompted to save the sketch with the .ino extension on save. 

Now, it’s finally time to open up the Arduino software. You’ll be presented with a window that looks something like this:
Arduino IDE annotated
  1. Verify: Compiles and approves your code. It will catch errors in syntax (like missing semicolons or parenthesis).
  2. Upload: Sends your code to the Arduino  board.
  3. New: This buttons opens up a new code window tab.
  4. Open: This button will let you open up an existing sketch.
  5. Save: This saves the currently active sketch.
  6. Serial Monitor: This will open a window that displays any serial information your Arduino board is transmitting. It is very useful for debugging.
  7. Sketch Name: This shows the name of the sketch you are currently working on.
  8. Code Area: This is the area where you compose the code for your sketch.
  9. Message Area: This is where the IDE tells you if there were any errors in your code.
  10. Text Console: The text console shows complete error messages. When debugging, the text console is very useful.
  11. Board and Serial Port: Shows you what board and the serial port selections.

MENU



File
NewCreates a new instance of the editor, with the bare minimum structure of a sketch already in place.
OpenAllows to load a sketch file browsing through the computer drives and folders.
Open RecentProvides a short list of the most recent sketches, ready to be opened.
SketchbookShows the current sketches within the sketchbook folder structure; clicking on any name opens the corresponding sketch in a new editor instance.
ExamplesAny example provided by the Arduino Software (IDE) or library shows up in this menu item. All the examples are structured in a tree that allows easy access by topic or library.
CloseCloses the instance of the Arduino Software from which it is clicked.
SaveSaves the sketch with the current name. If the file hasn't been named before, a name will be provided in a "Save as.." window.
Save as...Allows to save the current sketch with a different name.
Page SetupIt shows the Page Setup window for printing.
PrintSends the current sketch to the printer according to the settings defined in Page Setup.
PreferencesOpens the Preferences window where some settings of the IDE may be customized, as the language of the IDE interface.
QuitCloses all IDE windows. The same sketches open when Quit was chosen will be automatically reopened the next time you start the IDE.

Edit

Undo/RedoGoes back of one or more steps you did while editing; when you go back, you may go forward with Redo.
CutRemoves the selected text from the editor and places it into the clipboard.
CopyDuplicates the selected text in the editor and places it into the clipboard.
Copy for ForumCopies the code of your sketch to the clipboard in a form suitable for posting to the forum, complete with syntax coloring.
Copy as HTMLCopies the code of your sketch to the clipboard as HTML, suitable for embedding in web pages.
PastePuts the contents of the clipboard at the cursor position, in the editor.
Select AllSelects and highlights the whole content of the editor.
Comment/UncommentPuts or removes the // comment marker at the beginning of each selected line.
Increase/Decrease IndentAdds or subtracts a space at the beginning of each selected line, moving the text one
space on the right or eliminating a space at the beginning.
Find Opens the Find and Replace window where you can specify text to search inside the current sketch according to several options.
Find NextHighlights the next occurrence - if any - of the string specified as the search item in the Find window, relative to the cursor position.
Find PreviousHighlights the previous occurrence - if any - of the string specified as the search item in the Find window relative to the cursor position.

Sketch
Verify/Compile - Checks your sketch for errors compiling it; it will report memory usage for code and variables in the console area.
Upload Compiles and loads the binary file onto the configured board through the configured Port
Upload Using Programmer This will overwrite the bootloader on the board; you will need to use Tools > Burn Bootloader to restore it and be able to Upload to USB serial port again. However,     it allows you to use the full capacity of the Flash memory for your sketch. Please note that this command will NOT burn the fuses. To do so a Tools -> Burn Bootloader command must be             executed.
Export Compiled BinarySaves a .hex file that may be kept as archive or sent to the board using          other tools.
Show Sketch FolderOpens the current sketch folder.
Include LibraryAdds a library to your sketch by inserting #include statements at the start of your code. For more details, see libraries below. Additionally, from this menu item you can access the Library Manager and import new libraries from .zip files.
Add File... Adds a source file to the sketch (it will be copied from its current location). The new file appears in a new tab in the sketch window. Files can be removed from the sketch using the tab menu accessible clicking on the small triangle icon below the serial monitor one on the right side o the toolbar.

Tools
Auto FormatThis formats your code nicely: i.e. indents it so that opening and closing curly braces line up, and that the statements inside curly braces are indented more.
Archive SketchArchives a copy of the current sketch in .zip format. The archive is placed in the   same directory as the sketch.
Fix Encoding & ReloadFixes possible discrepancies between the editor char map encoding and other operating systems char maps.
Serial MonitorOpens the serial monitor window and initiates the exchange of data with any connected board on the currently selected Port. This usually resets the board, if the boar supports Reset over serial port opening.
BoardSelect the board that you're using. See below for descriptions of the various boards .
Port This menu contains all the serial devices (real or virtual) on your machine. It should automatically refresh every time you open the top-level tools menu.
ProgrammerFor selecting a harware programmer when programming a board or chip and not using the onboard USB-serial connection. Normally you won't need this, but if you're burning a bootloader to a new microcontroller, you will use this.
Burn BootloaderThe items in this menu allow you to burn a bootloader onto the microcontroller on an Arduino board. This is not required for normal use of an Arduino or Genuino board but is useful if you purchase a new ATmega microcontroller (which normally comewithout a bootloader). Ensure that you've selected the correct board from the Boards menu before burning the bootloader on the target board. This command also set the right fuses.

Help
Here you find easy access to a number of documents that come with the Arduino Software (IDE). You have access to Getting Started, Reference, this guide to the IDE and other documents locally, without an internet connection. The documents are a local copy of the online ones and may link back to our online website.

Find in Reference
This is the only interactive function of the Help menu: it directly selects the relevant
page in the local copy of the Reference for the function or command under the cursor.

14 comments:

  1. Is it possible to use PIC MCU on this software or it is only for Arduino MCU only?

    ReplyDelete
    Replies
    1. Glad you asked Aldrin. If you intend to use or program a PIC MCU using the Arduino Software, that is possible. You just have to do some sort-of code combination and coded editing. Hope this one helps. :)

      For further reading got to http://circuitcellar.com/cc-blog/execute-open-source-arduino-code-in-a-pic-microcontroller-using-the-mplab-ide/

      Delete
  2. Ma'am, what is the difference between Upload and Upload Using Programmer?

    ReplyDelete
    Replies
    1. Thanks for your question Daisy. Upload is used when your done with the sketches and you already want to burn it in the Arduino Board, take note that this happens directly and does not need any other materials while Upload Using Programmer is used if you have an external programmer (e.g. an AVR-ISP, STK500, or parallel programmer), you can burn sketches to the Arduino board without using the bootloader. This allows you to use the full program space (flash) of the chip on the Arduino board. So with an ATmega168, you'll get 16 KB instead of 14 (on an ATmega8 you'll get 8 KB instead of 7). It also avoids the bootloader delay when you power or reset your board. Hope this one helps. :)

      Delete
  3. maam, what is the purpose of the button below the serial monitor?

    ReplyDelete
    Replies
    1. Thanks for the curiosity Marco. Well the button below the serial monitor is a drop down menu that provides options such as New Tab, Rename, Delete, Previous Tab, Next Tab and the Title of the sketch/program that you are currently working with. Hope this helps :)

      Delete
  4. what if i used older version of arduino in doing my sketches, can i open that in the latest version?

    ReplyDelete
    Replies
    1. Glad you asked Maureen. Versions of the Arduino Software (IDE) prior to 1.0 saved sketches with the extension .pde. It is possible to open these files with version 1.0, you will be prompted to save the sketch with the .ino extension on save. Hope this one helps :)

      Delete
  5. Ma'am. What software that I can use other than Arduino software in programming on a arduino board?

    ReplyDelete
    Replies
    1. Thanks for asking Christian. It is possible to compile programs for the Arduino using other build tools (e.g. Makefiles and/or AVR Studio). You'll need to configure these to link against the appropriate files in the Arduino core libraries.

      Delete
    2. What is the difference of arduino software from the other software if I use them to compile programs in my arduino board?

      Delete
    3. Please specify the software that you are referring to Christian so that I can properly address your question. Thanks.

      Delete
    4. Makefiles or AVR Studio.

      Delete
    5. The language is the same. The available symbols are different. You can either use Arduino IDE or Atmel Studio.The Arduino libary is more of a wrapper to make it easy to do things, like digitalWrite, which you do not have by default in Atmel Studio. Hope this one answered your question.

      For further reading, go to http://electronics.stackexchange.com/questions/84593/how-different-is-the-arduino-language-than-atmel-studio-language.

      Delete