API Quick Reference

API Quick Reference

This page is a summary of the BrainPad API drivers found in all programming language options.  Note that each language has its own built-in functionality and each BrainPad has its own capabilities as well.


  • Print(object): Prints a string or a string representation of an object.
  • Wait(seconds): Holds the BrainPad from executing any further commands for a specific time. Fraction of seconds is supported. Wait(0.5) or Wait(1/2) will hold the BrainPad for half a second.
  • Out(element, value): Outputs a value to a specific element.
  • value = In(element): Reads and returns the value from an element.
  • OutIn(element, outValue, inValue): Advanced use, mostly used for data busses.
  • Release(element): Releases the pins used by an element so it can be used by a new element.

Learn more…

In & Out Elements

  • Digital(pin): A digital pin that can only handle 1 (high) or 0 (low). Supported by Out() and In().
  • Analog(pin): An analog pin that can handle any value 0 to 100, including fractions. All pins support Out(), but only pins labeled ANALOG support In().
  • Button(pin, scanTime): Detects a pin press (low state) on a pin from the time the In() was called to scanTime in the past. A scanTime of 0.5 will return 1 (pressed) if a button is pressed now or anytime up to 0.5 seconds in the past.
  • Sound(pin, playtime, volume): Generates sound on pins that support this feature. Supported pins are marked with the ~ symbol on the pinout. Playtime is the duration of play in seconds, with 0.5 being 1/2 a second. Volume can be anywhere 0 to 100. Only Out() is supported. Buzzer is a special pin that generates sounds on the on-board buzzer, if available.
  • Servo(pin): Generates the required signal to position a servo at a specific angle (or speed/direction). Only Out() is supported.
  • Neopixel(pin, Count): Controls a “count” of WS2812 smart LEDs. Only Out() is supported. Color is handled like on web, a hex number representing RRGGBB. Calling Out() with one value will set all LEDs to that value. Calling Out() with an array of values will set individual LEDs.
  • Accel(axis): Reads one of the three axes: AccelX, AccelY or AccelZ. For example, Accel(AccelX) to read the X axis. Only In() is supported and it returns the value of 2G. 1G = 100, range is between -200 to +200, or -2G to +2G.
  • Distance(triggerPin, echoPin): Reads the distance in cm from an ultrasonic sensor. Only In() is supported.
  • Touch(pin, level): Reads capacitive touch from the large pads. Use level to tweak sensitivity 0 to 100, use 50 by default.
  • Infrared(pin): Reads and decodes values from NEC encoded remote control. In() returns code of button presses.
  • I2cbus(address): Access the I2C bus using a 7-bit address.

Learn more…


  • Show(): Transfers the graphical memory to the Display/LEDs.
  • Text(object, x, y): Renders text at a specific location. If no string is used, it will automatically convert to string.
  • TextEx(object, x, y, width, height): Similar to Text() but adds scaling to change size of text.
  • Circle(x, y, radius): Renders a circle.
  • Line(x1, y1, x2, y2): Renders a line.
  • Rect(x, y, width, height): Renders a rectangular that starts at x/y for the specified width and height.
  • FillRect(x,y, width, height): Same as Rect(), but it fills it in.
  • Point(x, y, color): Sets or clears a point on the graphical memory.
  • Clear(): Clears the graphical memory.
  • Image(img, x, y): Renders an image at a specific location. Image is created using CreateImage.
  • Color(color): Sets the color for all drawing functions except for Point. Color is hex RRGGBB.
  • Brightness(level): Sets the brightness from 0 to 100.

Learn More…


Available pins P0. P1, P2…etc are optionally available as constants. For example, Digital(P1) instead of Digital(1). There are special pins that go to specific hardware on the BrainPad, like ButtonA/ButtonB for buttons. Buzzer and LED are used for onboard buzzer and LED if available.

For colors, we have included Black, White, Red, Green, Blue, Yellow, Magenta and Cyan.

Accelerometer uses AccelX, AccelY and AccelZ.