O'Reilly logo

openFrameworks Essentials by Denis Perevalov, Igor Tatarnikov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Programming an Arduino board

Let's start with the following steps:

  1. Download the Arduino IDE from www.arduino.cc (the current version is 1.0.6).
  2. Unzip and run it.
  3. Go to the File menu and click on New. A new window with an empty sketch (that is, an Arduino program) will be created.
  4. Fill it with the following code:
    void setup() {
      Serial.begin(9600);
    }
    
    void loop() {
      int analogIn = analogRead(A0);
      float value = analogIn / 1023.0;
      Serial.println(value);
    }

    Tip

    This code is written in the Arduino language. This language resembles the C, C++, and Java languages. It includes special constants, functions, and objects related to specific hardware capabilities of the Arduino board, such as analog inputs and serial ports.

    This code consists of two functions, setup() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required