Basic serial example?

There is something funny going on in serial land with Sparki. A ridiculously simple sketch like this doesn’t work:

void setup()
{
Serial.begin(9600);
}

void loop()
{

Serial.print("Foo\n");
delay(1000);

}

processing.app.SerialException: Serial port ‘/dev/tty.usbmodemfd121’ already in use. Try quitting any programs that may be using it.
at processing.app.Serial.touchPort(Serial.java:119)
at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:203)
at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)
at processing.app.Sketch.upload(Sketch.java:1671)
at processing.app.Sketch.exportApplet(Sketch.java:1627)
at processing.app.Sketch.exportApplet(Sketch.java:1599)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)
at java.lang.Thread.run(Thread.java:695)

I tried to reverse engineer the RoboRealm example, but that is much more complex than what I want.

What should be stupid simple but isn’t is a sketch that echoes whatever is typed into the serial console.

void setup()
{
Serial.begin(9600);
}

void loop()
{

# Echo whatever the user types
input = Serial.read();
Serial.write(input);

}

Looks like some other process is using your serial interface. Check if you have other programs using it. If you can’t solve it this way reboot the machine and try again.