Arduino Template Express – Creating a Sketch

In this post we’ll go over creating a sketch with Arduino Template Express.  I assume you have followed the instructions of how to install ATE from my previous post.  Launch Atmel Studio and select File\New\Project or Ctrl-Shift-N.

atmel-new-project

Select Arduino Sketch Wizard, give it a proper name and location and hit OK.  The wizard will be launched with the list of development boards you have configured during installation  or after installation by modifying the boards.xml file.

ate-wizard

I will use the Uno board for this example.  Pick an appropriate board from your setup and hit OK.  Atmel Studio will render a new project with the following layout.

ate-solution-explorer

This sketch flashes the on board LED and sends a running counter via the serial port.  Compile the sketch and  take a look at the output window.

ate-output

The sketch is compiled and as part of the compilation the template keeps track of how many successful and failed compilations have taken place.  It also keeps track of how many successful/failed deployments occur.  Let’s deploy this puppy.  Select Tool\Deploy or press deploy in the tool bar if you have it configured.  The output window should display the outcome of the deployment.  If you launch a terminal window and connect it to your development board data port, you will see a running counter every time the LED flashes.

Additional Goodies Included Provided by ATE

  • Take a look at Utility\BuildDate.cpp.  This file gets rebuilt every time the sketch is compiled.  It generates the time stamp of the last build and you can store it in ram, EEMEM or PROGMEM.  You can optionally use this information by calling GetBuildDate().
  • Utility\BuildInfo.cpp has ShowBuildInfo() to output build information to the Serial port.
  • Utility\BuildNumber.cpp keeps track of how many successful deployments has been made.  You can optionally use this information to keep track of your deployments.

That’s all for now.  In my next post we will go over creating libraries with ATE.

Print Friendly, PDF & Email

25 thoughts on “Arduino Template Express – Creating a Sketch

  1. Hello!
    Exelent project!
    Can You explain, how I can use it for load my simple project (without Arduino librares) to Arduino Mega board?

  2. You can install ATE and register the Mega board. You can then get rid off all the Arduino library references and that will leave the project arduino free. Add all your code and use the deploy option. Let me know if this is not clear and I’ll ping you for a more concrete discussion.

  3. Now I have two questions…
    1) Can I combine C code with Arduino code? For example, can I setup serial port with command Serial.begin() in my simple C code, not in setup() function?
    2) Scripts and Utility folders in Solution Explorer. Can I delete it from my project? Will be Deploy function still work?

  4. Yes, you can combine C/C++/ASM code in your sketches when you do it from Atmel Studio. The utility folder can be deleted. The scrip folder cannot. The arduino sketch loads the main function from the arduino library which invokes setup and loop. If you want to walk away from this convention, try setting up a main function in your sketch and see if the compiler does not bark and users your main function instead of the one in the Arduino library. If it does, recompile the arduino library (script is provided) and remove the main.cpp file. Not that will render all sketches generated by the wizard non operable since the sketch follow the Arduino convention.

  5. Thanks for all your hard work.

    It would be very handy to know what must be included to make a sketch work, and what is optional. For example, looking at the main.cpp and sketch.h, it appears that I only need to #include “Aruduino.h” in my sketch. The rest of sketch.h is optional.

    Thanks,
    -Steve

  6. Thank you very much for taking the time to write this tutorial. Has been an invaluable resource.

  7. I get an error when i want to open an new projekt. The
    error is: Oops – there has been an error reading the boards file.
    System.Exception: Failed to find or validate environment variable
    ATE_HOME. Return Value . Verify variable is defined and directory
    exist. at TexWizard.WizardModel.OpenBoardRegistry() at
    TexWizard.WizardModel.Init() at
    TexWizard.StudioWizard.RunStarted(Object automationObject,
    Dictionary`2 replacementsDictionary, WizardRunKind runKind,
    Object[] customParams) Can you help me? (sorry for my bad
    english)

  8. During the installation the ATE_HOME environment variable was not defined. Define the environment variable and point it to the directory where you installed ATE. Which OS are you using? Could you email me the install.log file from your documents directory. It will help me understand why the environment variable ATE_HOME was not set correctly. In my installation ATE_HOME is defined as a user environment variable with the value C:\Users\Omar\Documents\Arduino Template Express. For information on how to set environment variables in Windows see http://www.computerhope.com/issues/ch000549.htm

  9. Is there an URL to the full set of ATE ‘lessons’ and how does this great piece of work relate/work with a Due?

    Bob J (Docedison on the forum)

  10. Hi Robert, I have been posting different aspects of ATE on this blog. The work with the due is coming, but is very slow since my day job keeps getting in the way of my hobby. I expect within the next two months I will have something for the Due.

  11. I did everything like you said above but when I got to file->new project I observed that the Ok button is missing and there is no way for me to create the project

  12. I have an Arduino application that consists of six sketches; it compiles and uploads correctly in the Arduino IDE. When I try to build with ATE in the Atmel IDE, I get into all sorts of dependency trouble. I was able to run your sketch example without any problem. For my application, I made an Arduino project and added in the six sketch files. The order of compilation seems to be a problem. Some sketches are compiled before some of their variables are defined (in other sketches). Help.

  13. Hi Omar, i’ve a litle problem
    I can’t run the ATE wizard, it wil return an error

    Oops – there has been an error reading the boards file.
    System.Xml.XmlException:Root element is missing.
    at System.Xml.XmlTextReaderImpl.Throw(Exception e)
    at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
    at System.Xml.XmlTextReaderImpl.Read()
    at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
    at System.Xml.XmlDocument.Load(XmlReader reader)
    at System.Xml.XmlDocument.Load(String filename)
    at TexWizard.WizardModel.OpenBoardRegistry()
    at TexWizard.WizardMode.Init()
    at TexWizard.StudioWizard.RunStarted(Object automationObject, Dictionary2 replacementsDictionary, WizardRunKund runKind,Object[] customParams)

    the board.xml file is empty
    i’ve installing/reinstalling the program but the boards.xml is always empty and return always the same error

  14. hello
    if I want to creat a sketch, then comes an error message.
    I checked it and I got that “boards.xml” file is empty!
    I “ate” uninstalled and reinstalled, but it’s still not working.
    can you help me?
    Thank you

  15. Hi Omar,

    I’ve got the error message as HerrPitillo :

    Oops – there has been an error reading the boards file.
    System.Exception: Failed to find or validate environment variable
    ATE_HOME. Return Value . Verify variable is defined and directory
    exist. at TexWizard.WizardModel.OpenBoardRegistry() at
    TexWizard.WizardModel.Init() at
    TexWizard.StudioWizard.RunStarted(Object automationObject,
    Dictionary`2 replacementsDictionary, WizardRunKind runKind,
    Object[] customParams)

    Can you help to fix it?

    Thanks

  16. Define ATE_HOME as an environment variable and make it point to your installation directory.

  17. Try to run the install as admin and send the ATE.log in your documents directory.

  18. Hi!
    First off I would like to say Thank You for putting this together! It has been great!
    I do have one slight issue that I was hoping to get some assistance with. Whenever I try to use the Deploy tool it fails and I’m not sure why.
    The board I’m using is a Mega2560 -r3
    Here is the Output from Deploy:
    *******************************************************************
    Any Help would be GREATLY Appreciated!
    *******************************************************************

    Deploy script
    Executing local-deploy99.bat
    ———————————————————-
    Deploying “ArduinoSketch1” – Build 26
    The system cannot find the path specified.
    CANNOT Find output file “”C:\Users\Jordan\documents\atmel studio\6.1\ArduinoSketch1\ArduinoSketch1\scripts\output.txt”” – Aborting script

    “C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avrdude.exe” -C”C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf” -v -pAtmega328p -carduino -PCOM5 -Uflash:w:”C:\Users\Jordan\documents\atmel studio\6.1\ArduinoSketch1\ArduinoSketch1\Debug\ArduinoSketch1.hex”:i

    avrdude.exe: Version 5.11, compiled on Sep 2 2011 at 19:38:36
    Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
    Copyright (c) 2007-2009 Joerg Wunsch

    System wide configuration file is “C:\Program Files (x86)\Arduino\hardware\tools\avr\etc\avrdude.conf”
    Using Port : COM5
    Using Programmer : arduino
    avrdude.exe: stk500_getsync(): not in sync: resp=0x00
    avrdude.exe done. Thank you.

    Deployment Failed

    *************************************************************************
    END
    *************************************************************************

  19. Hi Omar, nice work. Just a quick question:
    Just installed templates on a fresh atmel 6.1 install. Not sure why but in the solution explorer I see a yellow exclamation triangle over the libarduinocore library. Everything compiles and builds ok but the triangle persists. Any ideas? Thanks, Martyn.

  20. Hello OMAR.
    I write you from Russia.
    Badly I am on friendly terms with English. If you write the answer that describe more simply.
    I downloaded the Arduino template express program from your site. I underwent all procedure as you described everything on the page passed without mistakes. I was happy. Further I started Atmel studio 6.1 and I followed your instructions. When pressing the Start Debugging button after a while when compilation of the program comes to an end outputs messages –
    “Debugging tool isn’t set. Please set correct tool, interface, and clock for the current target”
    Then opens to me an additional window with a simulator. Well type wants to tell that the payment which is connected to com6 is absent. I don’t know why so occurs.

  21. Hi Omar.
    Thank you very much this ATE. I am having difficulties in deploying the code. It gives me the following error. Please help. Thank you!

    Deploy script
    Executing local-deploy99.bat
    The system cannot find the file specified.
    The system cannot find the file specified.
    The system cannot find the file specified.
    The system cannot find the file specified.
    The filename, directory name, or volume label syntax is incorrect.
    ———————————————————-
    Deploying – Build 0
    else was unexpected at this time.

  22. Hi Omar
    Can a write a program with ATE in C rather than the C++ template that comes with it. please help!

  23. The Arduino library is in C++. You will not be able to take advantage of the Arduino libraries from C.

  24. Pingback: ATMEL | Pearltrees

  25. Pingback: Fix Arduino Sketch Errors Windows XP, Vista, 7, 8 [Solved]

Comments are closed.