Plaquette

Plaquette is an object-oriented, user-friendly, signal-centric programming framework for creative physical computing compatible with Arduino.

  • Object-oriented: Designed using input, output, and filtering units that can be easily interchanged in a plug-and-play fashion. Units are created using expressive code such as: DigitalOut led.
  • User-friendly: Allows users to quickly design interactive systems using an expressive language that abstracts away low-level functions. Example: led.on().
  • Signal-centric: Focused on real-time signal processing from inputs to outputs by providing simple data filtering tools for smoothing and normalization, as well as a new “pipe” operator (>>) for sending data from one unit to another.
  • Arduino compatible: Installed as an Arduino library and provides a replacement for the core Arduino functionalities while remaining fully compatible with Arduino code.

Note

Plaquette is still at an experimental stage of development. If you have any issues or questions, please contact the developers or file a bug in our issue tracker.

Note

The Plaquette reference text is licensed under a Creative Commons Attribution-Share Alike 3.0 License. Parts of the documentation has been borrowed and/or adapted from the Arduino Reference and from the Processing Reference texts.

Getting started

Step 1: Install Plaquette

If you do not have Arduino installed on your machine you need to download and install the Arduino IDE for your platform.

Once Arduino is installed, please install Plaquette as an Arduino library following these instructions.

Step 2: Your first Plaquette program

We will begin by creating a simple program that will make the built-in LED blink.

Create a new sketch

Create a new empty sketch by selecting File > New.

IMPORTANT: New Arduino sketches are initialized with some “slug” starting code. Make sure to erase the content of the sketch before beginning. You can use Edit > Select All and then click Del or Backspace.

Include library

Include the Plaquette library by typing:

#include <Plaquette.h>

Create an output unit

Now, we will create a new unit that will allow us to control the built-in LED:

DigitalOut myLed(13);

In this statement, DigitalOut is the type of unit that we are creating. There exist other types of units as we will soon see. DigitalOut is a type of unit that is attached to one of the many digital outputs on the Arduino board which can be set to one of two states (“on/off”, “high/low”, “1/0”).

The word myLed is a name for the object we are creating.

Finally, 13 is a parameter of the object myLed that specifies the pin it corresponds to on the board.

In English, the statement would thus read as: “Create a unit named myLed of type DigitalOut on pin 13.”

Create an input unit

We will now create another unit that will generate a signal which will be sent to the LED to make it blink. To this effect, we will use the SquareOsc unit type which generates a square wave oscillating between “on/high/one” and “off/low/zero” at a regular period of 2.0 seconds and a duty-cycle of 50%:

SquareOsc myOsc(2.0, 0.5);

Create the begin() function

Each Plaquette sketch necessitates the declaration of two functions: begin() and step().

Function begin() is called only once at the beginning of the sketch (just like the setup() function in Arduino). In our case, we do not to perform any special configuration at startup so we will leave the begin() function empty:

void begin() {}

Create the step() function

The step() function is called repetitively and indefinitely during the course of the program (like the loop() function in Arduino).

Here, we need to send the signal generated by the myOsc input unit to the myLed output unit. We will do this using Plaquette’s special >> operator:

void step() {
  myOsc >> myLed;
}

In plain English, the statement myOsc >> myLed reads as: “Take the value generated by myOsc and put it in myLed.”

Upload sketch

Upload your sketch to the Arduino board. You should see the LED on the board blinking once every two seconds at a regular pace.

Et voilà!

Full code

#include <Plaquette.h>

DigitalOut myLed(13);

SquareOsc myOsc(2.0, 0.5);

void begin() {}

void step() {
  myOsc >> myLed;
}

Step 3 : Experiment!

Period and duty

Try changing the period and/or duty-cycle parameters in the square wave unit construction:

SquareOsc myOsc(<period>, <duty-cycle>);
  • <period> can be any positive number representing the period of oscillation (in seconds)
  • <duty-cycle> can be any number between 0.0 (0%) and 1.0 (100%) and represents the proportion of the period during which the signal is “high” (ie. “on duty”)

What happens?

Adding and multiplying

Add another oscillator with a different period and duty cycle: multiply their values and send the result to the LED.

SquareOsc myOsc2(<period>, <duty-cycle>);
// ...
void step() {
  (myOsc * myOsc2) >> myLed;
}

Try adding their values instead: what do you see?

Use a conditional

Add a third oscillator that will “switch” between the two oscillators every 5 seconds using an if...else statement.

// TIP: omitting the duty-cycle parameter results in default value (0.5)
SquareOsc mySwitcher(5.0);
// ...
void step() {
  if (mySwitcher)
    myOsc >> myLed;
  else
    myOsc2 >> myLed;
}

ADVANCED: You can rewrite this expression in a more compact way using the ? : conditional operator:

void step() {
  (mySwitcher ? myOsc : myOsc2) >> myLed;
}

More examples

You will find more examples in File > Examples > Plaquette including:

  • Using a button
  • Using an analog input such as a photocell or potentiometer
  • Using an analog output
  • Basic filtering (smoothing, re-scaling)
  • Serial input and output

Credits

Developers:

Plaquette’s base source code was produced as part of a research project at labXmodal. A special thanks to Chris Salter for his support.

Plaquette borrows ideas from the Arduino, ChucK, mbed, Processing, and Pure Data.

License

Plaquette is distributed under the Gnu General Public License v 3.0.

The text of the Plaquette documentation is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Parts of the text was copied and/or adapted from the Arduino documentation. Code samples in the guide are released into the public domain.