Here is an example. This is the subroutine sketch code. Note no setup or loop functions. I would save this as myBlink.
void myBlink() {
digitalWrite(13,HIGH);
delay(500);
digitalWrite(13,LOW);
delay(500);
}
Then the main sketch code
void setup() {
Serial.begin(9600);
pinMode(13,OUTPUT);
}
void loop() {
Serial.println("tick");
myBlink();
}
After you enter this sketch, go to Sketch in the toolbar and select "add file", then find and select myBlink (the first code you entered). It will appear as a second tab, and you will be able to call the myBlink routine from your main sketch.
edit: I forgot to set pin 13 as an output. Corrected.