Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Robotics with the Board of Education Shield for Arduino

Robotics with the Board of Education Shield for Arduino

How the Hello Sketch Code Works

A function is a container for statements (lines of code) that tell the Arduino to do certain jobs.  The Arduino language has two built-in functions: setup and loop.  The setup function is shown below.  The Arduino executes the statements you put between the setup function’s curly braces, but only once at the beginning of the program.

In this example, both statements are function calls to functions in the Arduino’s built-in Serial pre-written code library: Serial.begin(speed) and Serial.print(val). Here, speed and val are parameters, each describing a value that its function needs passed to it to do its job.  The sketch provides these values inside parentheses in each function call.

Serial.begin(9600); passes the value 9600 to the speed parameter. This tells the Arduino to get ready to exchange messages with the Serial Monitor at a data rate of 9600 bits per second.  That’s 9600 binary ones or zeros per second, and is commonly called a baud rate.  

Serial.print(val); passes the message “Hello!” to the val parameter.  This tells the Arduino to send a series of binary ones and zeros to the Serial Monitor. The monitor decodes and  displays that serial bitstream as the  “Hello!” message.

After the setup function is done, the Arduino automatically skips to the loop function and starts doing what the statements in its curly braces tell it to do.  Any statements in loop will be repeated over and over again, indefinitely.  Since all this sketch is supposed to do is print one “Hello!” message, the loop function doesn’t have any actual commands. There’s just a notation for other programmers to read, called a comment.  Anything to the right of // on a given line is for programmers to read, not for the Arduino software’s compiler.  (A compiler takes your sketch code and converts it into numbers—a microcontroller’s native language.)

What is void?  Why do these functions end in ()? The first line of a function is its definition, and it has three parts: return type, name, and parameter list. For example, in the function void setup() the return type is void, the name is setup, and the parameter list is empty – there’s nothing inside the parentheses (). Void means ‘nothing’—when another function calls setup or loop, these functions would not return a value.  An empty parameter list means that these functions do not need to receive any values when they are called to do their jobs. 


Printer-friendly version
Codebender Hello Sketch
Prev
Modify the Sketch to Repeat
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress