2. Debug print - Spark Core

To create more complex app, I think I need to have a way to debug print. Yes you can do it very easily using serial port.
http://docs.spark.io/firmware/#communication-serial
I’m connecting my Core to MacBook Air by USB cable, so you would see debug print in your terminal in Mac.
Basically you need to call Serial.begin method, then use Serial.print() to print to the terminal.

// Example for debug print

void setup() {
  Serial.begin(9600); // open serial over US
}

void loop() {
   Serial.println("Hello, World");
   delay(1000); // Sleep 1 sec
}

Once you Flash the code, open your terminal then you’d see /dev/tty.usbxxxx.

% ls -la /dev/tty.usb*
crw-rw-rw-  1 root  wheel   20,  22 Sep  7 21:18 /dev/tty.usbmodem1411

Now you use screen command to see your output.

% screen /dev/tty.usbmodem1411  9600 
Hello, World
Hello, World
Hello, World
Hello, World
Hello, World
Hello, World
Hello, World
Hello, World
Hello, World
Hello, World
Hello, World
Hello, World
Hello, World

https://github.com/higepon/Spark-Core-Examples/blob/master/2.Debug%20print.ino