Upgrading to Arduino 1.0

Arduino 1.0 has hit the street.  And with that comes some backward compatibility issues.  These are the ones I needed to address to get ClockTHREE to run on Arduino 1.0.


ISSUE #1: “BYTE” keyword is no longer supported, but it is not required with the new Serial.write command.

FIX: Replace Serial.print(val, BYTE); with Serial.write(val);

ISSUE #2: “wprogram.h” not found.  It has been renamed “Arduino.h”

FIX: The release notes includes a handy pre-compiler directive to check of the arduino flavor you are using.

 #if defined(ARDUINO) && ARDUINO >= 100
 #include "Arduino.h"
 #include "WProgram.h"

ISSUE #3: Wire.send, Wire.recieve renamed to Wire.write and Wire.read resp.

FIX: At first I tried writing a couple of macros like FIX 1, but after it took me a long time to discover my mistake, I decided not to be clever here.  I now I just add a pre-compiler conditional for Arduino 1.0.  So you end up wrapping the old code with the check wherever “Wire.send” and “Wire.receive()” where.  Like this (and so on for read/receive).

// Arduino 1.0 compatibility
#if defined(ARDUINO) && ARDUINO >= 100
Wire.write("DATA", 4)
Wire.send("DATA", 4)
ISSUE #4: NewSoftSerial renamed to SoftwareSerial

FIX: This fix stinks, I don’t know a good way to solve it (suggestions welcome!) Arduino will scan the PDE file for ANY #includes EVEN when precluded by a pre-processor directive. The fix is to comment/uncomment the code for the correct version of Arduino.

For Arduino 1.0:
#include <SoftwareSerial.h>
SoftwareSerial sws(4, 5);
//#include <SoftwareSerial.h>
//SoftwareSerial sws(4, 5);

Leave a Reply