Arduino 1.0 is Out: Here’s What You Need To Know

Arduino
Arduino 1.0 is Out: Here’s What You Need To Know


The Arduino team just released version 1.0 of the Arduino development environment! With it comes a bunch of changes that will affect you, especially if you use any add-on libraries:

The language changes include modifications to the Serial class, addition of DHCP and DNS support to the Ethernet library, a new SoftwareSerial library, multi-file support in the SD library, modifications to the Wire library and UDP class, etc.

While the Arduino team has been hard at work on 1.0, we’ve been working on an update to Michael Margolis’ Arduino Cookbook, and to help you make sense of Arduino 1.0, we’re sharing Michael’s Appendix H, Migrating to Arduino 1.0.

Although the Arduino Cookbook won’t be in print (or ebook) for a couple more weeks, you can get in on the action now with our early release: Buy it now on oreilly.com:

With this digital Early Release edition of Arduino Cookbook, 2nd edition, you get the entire book bundle in its earliest form – the author’s raw and unedited content – so you can take advantage of this content long before the book’s official release. You’ll also receive updates when significant changes are made, as well as the final ebook version.

Appendix H. Migrating to Arduino 1.0

Although it should not difficult to get sketches written for previous Arduino versions working with Arduino 1.0, that release has important changes you need to be aware of. The first thing you will notice when launching the software is the look of the IDE. Some icons are different from previous versions of the software and there are changes and additions in the menus. The error messages when dealing with selecting boards have been improved and the new ADK and Ethernet boards have been added.

More significant are changes in the underlying core software and libraries. The stated purpose of 1.0 is to introduce disruptive changes that will smooth the way for future enhancements but break some code written for older software. New header files mean that older contributed libraries will need updating. Methods in Ethernet and Wire have been changed and there are subtle differences in the print functionality.

New functionality has been added to Streams (the underlying class that anything that uses .print() statements), Ethernet, Wire (I2C), and low level input/output.

Improvements have been made to the way libraries handle dependencies and to simplify the support for new boards. Because of these changes, third party libraries will need updating, although many popular ones may already have been updated.

The file extension used for sketches has been changed from .pde to .ino to differentiate Processing files from Arduino and to remove the inconvenience of accidental opening of a file in the wrong IDE.

Sketches opened in the 1.0 IDE will be renamed from .pde to .ino when the file is saved. Once renamed, you will not be able to open them in older versions without changing the extension back. There is a option in the File→Preferences dialog to disable this behavior if you don’t want the files renamed.

The following is a summary of the changes you need to make for 1.0 to compile sketches written for earlier releases. You will find examples of these in the Chapters covering Serial, Wire, Ethernet, and Libraries.

Migrating print statements

There are a few changes in how print() (or println) is handled:

Working with byte datatypes
print(byte)now prints the integer value of the byte as ASCII characters, previous releases sent the actual character. This affects Serial, Ethernet, Wire or any other library that has a class derived from the Print class. Change:

Serial.print(byteVal)

To:

Serial.write(val); //send as char
The BYTE keyword
The BYTE keyword is no longer supported. Change:

Serial.print(val, BYTE)

To:

Serial.write(val); //sends as char
Return values from write() methods
Classes derived from Print must implement a write method to write data to the device that the class supports. The signature of the write method has changed from void to size_t to return the number of characters written. If you have a class derived from Print you need to modify the write method as follows and return the number of characters written (typically 1). Change:

void write

To:

size_t write
Migrating Wire (I2C) statements
You’ll need to make some changes when working with the Wire library. First, Wire method names have been changed to make them consistent with other services based on Streams. Change:

Wire.send()

To:

Wire.write()

And change:

Wire.receive()

To:

Wire.read()

Second, the write method requires types for constant arguments. You now need to specify the type for literal constant arguments to write. So, for example, change:

write(0x10)

To:

write((byte)0x10)

Migrating Ethernet statements

Arduino 1.0 changes a number of things in the Ethernet library.

Client class
The client Ethernet classes and methods have been renamed. Change:

client client(server, 80)

To:

EthernetClient client;

And change:

if(client.connect())

To:

if(client.connect(serverName, 80)>0)

Note: client.connect should test for values > 0 to ensure that errors returned as negative values are detected.

Server class

Change:

Server server(80)

To:

EthernetServer server(80)

And change:

UDP

To:

EthernetUDP

Migrating Libraries

If your sketch includes any libraries that have not been designed for 1.0 then you will need to change the library if it uses any of the old header files that have been replaced with the new Arduino.h file. If you include any of these libraries, change:

#include "wiring.h"
#include "WProgram.h"
#include "WConstants.h"
#include "pins_arduino.h"

To:

#include "Arduino.h"

You can use a conditional include to enable libraries to also compile in earlier versions. For example, you could replace #include "WProgram.h" with the following:

#if ARDUINO >= 100
  #include "Arduino.h"
#else
  #include "WProgram.h"
#endif

New Stream Parsing functions

Arduino 1.0 introduced a simple parsing capability to enable finding and extracting strings and numbers from any of the objects derived from Stream, such as: Serial, Wire and Ethernet. These functions include:

    find(char *target);
    findUntil(char *target,char *term);
    readBytes(buffer,length);
    readBytesUntil(term,buffer,length);
    parseInt();
    parseFloat();

36 thoughts on “Arduino 1.0 is Out: Here’s What You Need To Know

  1. Gregg Levine says:

    Well that’s good. Now we need to make the whole thing so easy to use that someone who’s not done this before will be able to do so. In fact it should be easier then BASIC to use.

    1. Anonymous says:

      You’re asking to make C easier than BASIC? 

      What?

      So you’re asking Arduino to use LOGO as the language instead of C.

    2. Hendry Betts III says:

      Gregg, 

      I could not disagree more.  The Arduino language should not be “easier then BASIC” because you can’t compile basic to byte code without HUGE overhead.  What they have done is disambiguate some classes and make includes easier.  Please do NOT cripple Arduino by wrapping it in a BASIC type construct.

    3. Anonymous says:

      Gregg… Google the words “scratch arduino”.   Scratch allows you program graphically.   there are various versions out there being built for Arduino.    More info on Scratch is here http://en.wikipedia.org/wiki/Scratch_(programming_language)

      Also MIT has a Scratch forum here:  http://scratch.mit.edu/forums/viewforum.php?id=26 

      1. drwho8 (@drwho8) says:

        Actually, all of you are not understanding what I said properly, then. The implication was that the Arduino software should be easier then BASIC, specifically the style of BASIC on the ones from Parallax. Not the idea of running a BASIC interpreter on the device. Although they are available. Nearly every time I wanted to use an Arduino for something complicated, (then) I found that as the wire connecting the components to the Arduino, the code written on the IDE screen was rapidly evolving into spaghetti code, difficult to understand, let alone follow the steps involved.

        And yes I did look into Scratch when it was first announced.

  2. Anonymous says:

    Thanks for the update.   I ran into the Wire library changes last night.   Not a big deal but it does play havoc on the book authors I imagine.

  3. Leif Burrow says:

    does this require updating the bootloader?

    1. Anonymous says:

      No; I have not had to update the bootloader for any of my Arduinos, and some of them are quite old.

      1. Leif Burrow says:

        Great, Thanks!

      2. Shawn Wallace says:

        One more question: Is it Arduinos or Arduinae?

        1. Anonymous says:

          It’s Arduinos all the way down.

  4. Martin Nedbal says:

    Unfortunately Arduino 1.0 breaks EthernetServer. It initalizes, returns an instance of connected EthernetClient but calls to read() keep returning garbage instead of data;( Going back to 022…

    1. Anonymous says:

      I ran into the Ethernet problem, too. One of my colleagues has isolated the problem and it is being patched: http://arduino.cc/pipermail/developers_arduino.cc/2011-December/006015.html

      1. Martin Nedbal says:

        Hi, this alone did not solve it for me. I got ethernet finally working by applying this patch: http://code.google.com/p/arduino/issues/detail?id=605&start=200

  5. John says:

    A very tricky one to add to the original article:
    Now that you all have to use serial.write(), instead of print() for BYTE variables, you can’t do serial.write(0) or serial.write(”). You will have to do serial.write((uint8_t)0). This only affects the value zero. Not doing this makes it ambiguous since now write(char*) is no longer a virtual method.

    1. tim says:

      Thanks!!

  6. HopWorks says:

    Is Arduino 1.0 compatible with the chipKIT Max32? If not, is there planned for a MPIDE that uses Arduino 1.0? Thank you for all you post!

  7. farai says:

    Thank you for the post, i have a question though…
    The reference on the arduino website states that Serial.write() writes binary data to the serial port and returns the number of bytes written. My question is, how do you get the numer of bytes written?

    Thank you…

Comments are closed.

Discuss this article with the rest of the community on our Discord server!
Tagged

I'm a tinkerer and finally reached the point where I fix more things than I break. When I'm not tinkering, I'm probably editing a book for Maker Media.

View more articles by Brian Jepson

ADVERTISEMENT

Maker Faire Bay Area 2023 - Mare Island, CA

Escape to an island of imagination + innovation as Maker Faire Bay Area returns for its 15th iteration!

Buy Tickets today! SAVE 15% and lock-in your preferred date(s).

FEEDBACK