

Now you’re ready to verify and compile the sketch.
#ARDUINO CODE LANGUAGE PRINT TO CONSOLE SERIAL#
The basic idea for this code is to make the Arduino blink the L LED connected to digital port 13 on the Arduino once per second, and also output a message to the Arduino serial port, counting each blink.Īfter you enter the code into the editor window, choose File > Save As from the menu bar to save the sketch as sketch0401. The main point now is to have a sketch to practice compiling and running.

You’ll learn what all these different lines of code mean as you go through the rest of the hours, so don’t worry too much about the code for now. Serial.print(“Blink #”) Serial.println(counter) LISTING 4.1 The sketch0401 Code int counter = 0 Enter this code into the Arduino IDE editor window. Listing 4.1 shows the code for the sketch0401 file that we’ll use to test things out. This makes it easier to pick out syntax errors, and comes in handy when you’re trying to debug your sketch. Where mmm is a three-letter abbreviation of the month, dd is the two-digit numerical date, and x is a letter to make the sketch name unique for the day (for example, sketch_jan01a).Īs you type your sketch code into the editor window, the editor will color-code different parts of the sketch code, such as making function names brown and text strings blue.

The name of the new sketch appears in the tab at the top of the editor window area, in the following format: sketch_ mmmddx When you open the Arduino IDE, the editor window starts a new sketch. Now that you’ve seen the basics for creating an Arduino program, let’s dive in and create a simple sketch to get a feel for how things work. Learn More Buy Creating Your First Sketch Arduino Programming in 24 Hours, Sams Teach Yourself
