Built-in Functions

Built-in Functions

We are ready to cover some basic built-in functions to get us started. These functions are built inside both the BrainPad itself and in the programming language we’re using.


This lesson assumes you’re already completed the Coding Intro lesson.


Built-in functions, sometimes referred to as API (Application Programming Interface), are functions that are pre-made and found internally in the system. Just like how we make a function for later use, someone created functions that are already found in the device that we can just use.

Device Specific

Some of these functions are provided by the specific devices’ libraries. Print() is one of them. The Print() function outputs whatever argument it is given to the screen.

This image has an empty alt attribute; its file name is BrainPadPulse_API_1.gif

In the case of BrainPad Tick, the text will scroll across the LEDs. If the text being printed is a single character, then that one character will just show on the LEDs.

Another function is Wait(). Just as you may be thinking, Wait() forces the BrainPad to pause for some time. The following code will output 1 and then pause for one second, then it outputs 2 and pauses for another second, and finally ends with output of 3.


The complete list of device-specific functions are found on the Due Link website, for Python and .NET C#.

Language Built-ins

There are some functions that are built-in as part of the programming languages we’re using. While languages may have different definitions of those functions, they provide a similar outcome.

For example, one of these functions is a random number generator. We will show how it is used in C# and in Python.

var rnd = new System.Random();

var myRandomNumber = rnd.Next(100);
myRandomNumber = rnd.Next(100);
import random

myRandomNumber = random.randint(0,100)
myRandomNumber = random.randint(0,100)

In C#, Random object comes from the System namespace, needing System.Random(). Python needs an import of the random library. From there, the use is almost identical. C# Next() and Python randint() return the next random number.

The argument in the above example (the 100) tells the function to give us a random number that is no more than 100.

Can you use those random numbers to plot points or shapes on the screen at random locations? Just keep the shapes within the screen by limiting the random number to a max of the screen size. Don’t know how to draw yet? Well, that is next!

var rnd = new System.Random();

    var x = rnd.Next(127);
    var y = rnd.Next(64);
    BrainPad.Display.SetPixel(1,x, y);
import random

while True:
    x = random.randint(0,127)
    y = random.randint(0,64)
    BrainPad.Display.SetPixel(1, x, y)

What’s Next?

You now know enough coding and you deserve to start with some fun topics. The next step is to learn about the drawing function.


Do animals and humans have built in functions at birth? Why do some newborn animals get up as soon as they are born and start following their mom? Why does a parent is willing to risk their life to protect their children? Is this something they learned or it is built in our brains?

Content Licensing

Twitter Feed
Hot off the press!
November 24, 2023
November 20, 2023
November 15, 2023
November 15, 2023
November 9, 2023
November 9, 2023
October 31, 2023
October 24, 2023