If we want a person to get us a ball, we would say "Please get me the ball".
If we want a computer to get the ball, we might say "get(ball);"
How does code work?
But what does it all mean? Let's break it down line by line:
#include <CODEKITTY.h>
This line, called an include tells the Arduino to look in a file called CODEKITTY.h for a list of things to add into the code. This gives you a way of re-using bits of code without having to type them all out every time. This list is called a Library, and usually they contain functions you can use in your code.
/*
This is a comment.
Comments are ignored by the arduino.
They are just a way for you to keep notes in your code
*/
These lines (actually anything put between /* and */) are called comments. Comments are a way for a coder to write notes in their code, so that somebody looking at their code can know something. Maybe you want to explain how a function is meant to be used, or what you had in mind when you came up with a bit of code. No matter what they say, comments are ignored (not processed) by the Arduino.
void setup(){
This line starts the setup() function. The setup function is automatically added to every sketch and needs to be there for the Arduino sketch to work (even if you don't put any code in it). Any code you put on a new line after the curly brace { is run once when the Arduino first turns on.
So what's with the { } anyway? The code of functions (in other words, the instructions that the processor follows when that function is used) are put between the curly braces. It always starts with { and ends with }. This way the computer knows which instructions are supposed to happen when setup() is called (when the Arduino first starts up).
CODEKITTY kitty;
This line declares an instance of the CODEKITTY object. In other words, it makes a copy of the Code Kitty software and names it 'kitty'. From then on, whenever you want to tell Code Kitty to do something, you can say 'kitty' instead of CODEKITTY at the start of the function you are using. This step is required to be able to use the Code Kitty library (cklib), and you need it as the first line inside your loop() and setup() functions.
kitty.forward(1000);
kitty.left(500);
kitty.risingBeep();
These lines are the instructions that the Code Kitty will follow when it turns on. In this case, it says to go forward for one second (times are in milliseconds or ms for short, and one second is one thousand milliseconds. So half a second is 500ms, two seconds is 2000ms, and so on), and then turn left for 500ms, and then make a rising beep (three beeps in rising pitch).
This code is just provided as an example (try it and see how it works on your code kitty!), but you can put any code here that you want.
Please check out the Code Kitty Function reference for a complete list of the functions available in the Code Kitty library (cklib).
void loop(){
This line starts the loop() function. Any code within the curly braces of the loop function will be run over and over again until something stops it.