http://arduino.cc/en/Tutorial/ShftOut12 understanding code

Dear Forum members, I am trying to understand the http://arduino.cc/en/Tutorial/ShftOut12. I get about half of it but I am stuck on the concept of custom functions. I just don't get what a custom function is like the one in the code: registerWrite. I have read the explanation of this code in Arduino for dummies but am still dumb. Can you help. JK

The whole purpose of computer programming is writing functions. There is nothing strange about that one.

A function is a series of instructions for what you want the computer to do.

That function will set one bit in a byte to one, and then send that byte to the shift register chip, which will cause one of the LED's to light up.

You need to find the book for idiots, and then progress to the book for dummies.

A custom function is a new concept for me and I am having trouble understanding it. In previous sketches it seemed that the end of the loop was the end of the program, but here there is a whole new section which seems to describe the custom function registerWrite. The function does not highlight in orange which most functions do so I assumed the compiler would give me an error when I compiled. Thank you Michinyon for your kind words. The third line of your reply was actually useful.

The function does not highlight in orange which most functions do so I assumed the compiler would give me an error when I compiled

The compiler neither knows nor cares whether a function name highlights or not; that's simply a nicety provided by the IDE and the person who added the appropriate keywords.txt file.

Think of programming as a hierarchy of functions - at the top, invisible and mysterious (in the Arduino world) is the God Function "main()", which first calls another invisible function "init()", then it calls one you can see called "setup()", then finally, and forevermore, a function called "loop()".

These functions can call other functions (and even themselves, though I don't recommend it!), up to the limit imposed by the size of the stack, which on an Arduino, is pretty small.

As you gain experience, you will start writing your own functions, each of which (hopefully) is designed to do one small task. Try the following program:

int number;

void setup() {

  Serial.begin(9600);

  Function1();
  Function2();
  Function3();
  Function4();
  Serial.print("Back in setup(), number = ");
  Serial.println(number);
  
}

void loop() {
}

void Function1()
{
  number = 10;
  Serial.println(number);
}

void Function2()
{
  number = number * number;
  Serial.println(number);
}

void Function3()
{
  number = number + 50;
  Serial.println(number);
}

void Function4()
{
  number = number / 2;
  Serial.println(number);
}

If you can move the definition of number from before setup() to inside of setup() and get the program to show the same results, you're on your way to understanding how functions work.

Thanks. This is helpful. I did not know you could write your own functions I thought you could only call those established in the language. I will still have questions about the example http://arduino.cc/en/Tutorial/ShftOut12 but I am determined to figure this one out. JK