Learn Arduino with Olympia Circuits
Learn Arduino
  • Home
    • Get Started
    • How to Use This Site
  • Electronics
    • The Basics
    • Electricity Flows like Water
    • Electronic Components
    • The Arno Board
  • Programming
    • The Basics
    • setup and loop Blocks
    • Variables and Arrays
    • Connecting with the Pins
    • Flow Control >
      • if Statement
      • Loops
      • Delays
    • Functions
    • Serial Communication
    • USB
    • Some Thoughts
  • Projects
    • Projects 1 >
      • 1.01: Blink
      • 1.02 Blink x2
      • 1.03 Blink Faster
      • 1.04 LED Chase!
      • 1.05 Wait To Blink
      • 1.06 Blink a Little Faster Now
      • 1.07 LED Fade
      • 1.08 RGB Blink
      • 1.09 Change RGB Color with SW1
      • 1.10 Fade RGB Colors
      • 1.11 Reaction Time Game
    • Projects 2 >
      • 2.01 Hello World
      • 2.02 Talk Back
      • 2.03 ASCII Values
      • 2.04 Ski Game
      • 2.05 Demonstration of the String Object
    • Projects 3 >
      • 3.01 Read the Potentiometer
      • 3.02 ASCIIbet Soup
      • 3.03 Potentiometer sets LED Brightness
      • 3.04 Potentiometer Sets Blink Rate
      • 3.05 LED Chase, Part II
    • Projects 4 >
      • 4.01 Bringing the Piezo to Life
      • 4.02 Controlling the Piezo with a Function
      • 4.03 Piezo C Major
      • 4.04 Piezo Greensleaves
      • 4.05 Piezo Metronome
      • 4.06 Piezo as an Input
      • 4.07 Piezo as an Input 2
      • 4.08 Metronome II
      • 4.09 Piezo Playback
      • 4.10 Piezo Fireworks
      • 4.11 Piezo Mosquito
    • Projects 5 >
      • 5.01 The Phototransistor
      • 5.02 Light and Sound
      • 5.03 Light and Sound II
    • Projects 6 >
      • 6.01 EEPROM
      • 6.02 I2C Address Scan
      • 6.03 Read the I2C Temperature Sensor
      • 6.04 High Temperature Alarm
    • Projects 7 >
      • 7.01 Arno Phone Home
      • 7.02 Keyboard Alphabet
      • 7.03 Move Mouse
      • 7.04 Draw Squares
    • Special Projects >
      • Bike Light Demo
  • References
    • Arno Pin Key
    • Arno Schematic
    • Project Index

Project 2.01 Hello World

This is our first demonstration of the serial monitor.  We program the Arno the send messages back to the user.  The messages are viewed in the serial monitor.


Concepts: Serial object

Circuits: none


Select Sketch

///////////////////////////////////////////////////
//Project 11 Hello World!
int counter = 1;
void setup(){
Serial.begin(0);
}
void loop(){
Serial.println(Hello World);
Serial.print(Counter = );
Serial.println(counter);
delay(1000);
counter++;
}

This project uses the Serial object for communication.  You must create an instance of this object in the loop() block if you want to use serial communication:

Serial.begin(9600);

The value in parentheses is a holdover from older Arduino boards.  In the past, we used to set the baud rate (9600 was a common rate and we still use it out of habit).  The number in parentheses doesn’t matter with the Arno, which uses direct USB communication, but a number is still required by the compiler to avoid an error.  For older Arduino boards like the Uno or Duemillanove, the baud rate set in the Serial.begin statement must match the baud rate set in the serial monitor window of the IDE.  The baud rate is set in the serial monitor by a pull-down tab in the lower-right corner of its window.  Again, it doesn’t matter for the Arno or other boards based on the 32U4 chip.

The Serial.print and Serial.println commands both output their contents to the serial monitor. Serial.print doesn’t start a new line; the next text comes out on the same line. These two commands print their output to the same line:

Serial.print("Counter = ");

Serial.println(counter);

However, the second command starts a new line so that when we we reach the top of the loop() block again, the output begins on a new line.

Back to Projects 2

Copyright Olympia Circuits LLC 2014. All Rights Reserved.