This page includes the common BrainPad API drivers found on all programming languages. 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.
- Digital(pin): A digital pin that can only handle to 1 (high) or 0 (low). Supported by Out() and In(). “led” is a special pin that is used to control the on-board LED, if available.
- Analog(pin): An analog pin that can handle any value 0 to 100, including fractions. Supported by Out() and 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 in the past. “A” and “B” can be used to indicate the on-board buttons.
- 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, angle): Generates the required signal to position a servo at a specific angle, 0 to 180. 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, X, Y or Z. For example, Accel(‘X’) to read the X axis. Only In() is supported and it returns the value in 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.
- Show(): Transfers the graphical memory to the Display/LEDs.
- Clear(): Clears the graphical memory.
- Text(object, x, y): Renders text at a specific location. If not string us used, it will automatically convert to string.
- TextEx(object, x, y, width, height):
- 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 up.
- Point(x, y, color): Sets or clear a point on 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 function except for Point. Color is hex RRGGBB.
- Brightness(level): Sets the brightness from 0 to 100.
Available pins P0. P1, P2…etc are optionally available as constants. For example, Digital(P1) instead of Digital(1).