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();

What will the next generation of Make: look like? We’re inviting you to shape the future by investing in Make:. By becoming an investor, you help decide what’s next. The future of Make: is in your hands. Learn More.

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
Discuss this article with the rest of the community on our Discord server!

ADVERTISEMENT

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

Prices Increase in....

Days
Hours
Minutes
Seconds
FEEDBACK