A library for Arduino that provides useful classes for physical computing projects, including joystick input, OLED graphics, signal filtering, and more. Created for courses at the Makeability Lab, University of Washington.
Officially available in the Arduino Library Manager — search for MakeabilityLab.
📖 Interactive textbook: makeabilitylab.github.io/physcomp
| Class | Header | Description |
|---|---|---|
ParallaxJoystick |
ParallaxJoystick.hpp |
Read input from a Parallax 2-Axis Joystick, with support for different orientations |
Button |
Button.hpp |
Debounced digital button with press/release detection |
Shape, Rectangle, RoundRect, Triangle, Circle, Ball |
Shape.hpp |
Drawing primitives with collision detection, velocity, and boundary checking for monochrome OLEDs (Adafruit SSD1306) |
ScrollingLineGraph |
ScrollingLineGraph.hpp |
Single-value scrolling line graph for OLEDs |
ScrollingLineGraphMultiValue |
ScrollingLineGraphMultiValue.hpp |
Multi-value scrolling line graph with per-line symbols |
MovingAverageFilter |
MovingAverageFilter.hpp |
Sliding-window moving average for smoothing sensor input |
ColorName |
ColorName.hpp |
Named RGB colors with closest-color matching (e.g., for color sensors) |
FileUtils |
FileUtils.hpp |
SD card file utilities: list, count, and search files by extension |
In the Arduino IDE: Sketch → Include Library → Manage Libraries…, then search for "MakeabilityLab" and click Install.
This will also automatically install the required dependencies (Adafruit SSD1306 and Adafruit GFX).
git clone https://github.com/makeabilitylab/makelab-arduino-lib.gitThen copy (or symlink) the folder into your Arduino libraries directory:
| OS | Libraries path |
|---|---|
| Windows | C:\Users\<YourName>\Documents\Arduino\libraries\ |
| macOS | ~/Documents/Arduino/libraries/ |
| Linux | ~/Arduino/libraries/ |
After installing, open one of the example sketches below (File → Examples → Makeability Lab). If it compiles, you're all set.
Include the header you need at the top of your sketch:
#include <Shape.hpp> // for Shape, Rectangle, RoundRect, Triangle, Circle, Ball
#include <ParallaxJoystick.hpp> // for joystick input
#include <Button.hpp> // for debounced buttonsThese example sketches are included with the library (File → Examples → Makeability Lab):
| Example | What it demonstrates |
|---|---|
| BallBounceObjectOriented | Ball with velocity, boundary detection, isOutOfBoundsX/Y |
| BallBounceShapes | Shows all shape, collision detection with overlaps() |
| FlappyBird | Game loop, subclassing Rectangle, collision with overlaps() |
| Pong | Two-player input (joystick + buttons), ball-paddle collision, scoring |
| MoveBallJoystickTest | ParallaxJoystick controlling a Ball on the OLED |
| CollisionTest | Polymorphism with Shape pointers, mixed Ball/Rectangle collision |
Some classes require external libraries. If you installed via the Library Manager, these are handled automatically. Otherwise, install them manually via Sketch → Include Library → Manage Libraries…:
| This library class | Requires |
|---|---|
Shape, Rectangle, RoundRect, Triangle, Circle, Ball |
Adafruit SSD1306, Adafruit GFX |
ScrollingLineGraph, ScrollingLineGraphMultiValue |
Adafruit SSD1306 |
FileUtils |
SD (built-in) |
ParallaxJoystick, Button, MovingAverageFilter, ColorName |
(none — standalone) |
Handles analog input from the Parallax 2-axis joystick, with support for different physical orientations (UP, RIGHT, DOWN, LEFT).
ParallaxJoystick joystick(A0, A1); // up/down pin, left/right pin
ParallaxJoystick joystick(A0, A1, 1023, RIGHT); // with max analog value and orientation
void setup() { }
void loop() {
joystick.read();
int upDown = joystick.getUpDownVal(); // 0–1023
int leftRight = joystick.getLeftRightVal(); // 0–1023
}Debounced button input with configurable debounce time and active-low/active-high support.
Button myButton(2); // pin 2, 25ms debounce, internal pull-up, active low
void setup() {
myButton.begin(); // must call before read()
}
void loop() {
myButton.read();
if (myButton.isPressed()) { /* button is held down */ }
if (myButton.wasPressed()) { /* button was just released */ }
}Drawing primitives for SSD1306 OLEDs with bounding-box collision detection. All shapes support velocity (setSpeed, update, reverseXSpeed, reverseYSpeed) and boundary checking (isOutOfBoundsX, isOutOfBoundsY, forceInside).
Circle ball(64, 32, 5); // xCenter, yCenter, radius
Rectangle paddle(0, 28, 5, 8); // x, y, width, height
ball.setDrawFill(true);
ball.setSpeed(1, 1); // any shape can have velocity
void loop() {
ball.update();
if (ball.isOutOfBoundsX(0, 128)) ball.reverseXSpeed();
if (ball.isOutOfBoundsY(0, 64)) ball.reverseYSpeed();
ball.forceInside(0, 0, 128, 64);
if (ball.overlaps(paddle)) {
ball.reverseXSpeed();
}
display.clearDisplay();
ball.draw(display);
paddle.draw(display);
display.display();
}Additional shape classes:
RoundRect button(10, 2, 50, 12, 3); // x, y, width, height, cornerRadius
Triangle arrow(60, 20, 80, 32, 60, 44); // three (x,y) verticesBall is kept for backwards compatibility — it's just a Circle with checkXBounce/checkYBounce convenience methods (equivalent to isOutOfBoundsX/isOutOfBoundsY on any shape).
Smooths noisy sensor input with a sliding-window average.
MovingAverageFilter filter(10); // window size of 10
void loop() {
int raw = analogRead(A0);
filter.add(raw);
int smoothed = filter.getAverage();
}Real-time scrolling graph for visualizing sensor data on an OLED.
ScrollingLineGraph graph(128, 64); // width, height in pixels
graph.setDataLabel("Sensor");
void loop() {
graph.addData(analogRead(A0));
display.clearDisplay();
graph.draw(display);
display.display();
}Like ScrollingLineGraph but supports multiple data series with distinct symbols.
PointSymbol symbols[] = {CIRCLE, SQUARE};
ScrollingLineGraphMultiValue graph(2, symbols);
void loop() {
graph.addData(0, analogRead(A0)); // line 0
graph.addData(1, analogRead(A1)); // line 1
display.clearDisplay();
graph.draw(display);
display.display();
}Jon E. Froehlich Professor, Allen School of Computer Science & Engineering, University of Washington Director, Makeability Lab
This library is released under the MIT License.