Basics

Here you will find the basics of programming the Calliope mini

LED-Matrix

RGB-LED

Speaker

Button A

Button B

Pin -

Pin +

Pin P0

Pin P1

Pin P2

Pin P3

Motionsensor

Lightsensor

Temperaturesensor

Microphone

Radio

Output
LED-Matrix

On the LED matrix of the Calliope mini there are 5 x 5 = 25 red LEDs, with which not only numbers and texts but also pictures and even animations can be displayed. and texts, but also pictures and even animations. Larger screens work in a similar way screens work in a similar way, where the luminous dots, also known as pixels, are much more more condensed are much more condensed.

Show text

Individual letters or even whole words and sentences can be displayed. In Open Roberta you can set whether the text is displayed as individual characters or scrolls through the screen as an animation. the screen as an animation. In MakeCode, the text automatically scrolls across the LED display if it is longer than one letter.


Show numbers

Single digits or larger numbers with decimal places can be displayed. In Open Roberta, you can set whether larger numbers are displayed as single digits, or scroll through the screen as an animation. In MakeCode, numbers that have more than one digit automatically run through the screen as an animation.


Show symbols

Predefined symbols and images can be selected and displayed on the LED matrix.


Show own images

For your own symbols, the individual light points can be switched on or off individually.


RGB-LED

The RGB LED can shine in a wide variety of colours. To be precise, in 256^3 = 16.7 million colours. colours, because the different colours are mixed together additively from three primary colour tones, which, when programmed, have a value range of 0-255. Additive colour mixing is based on the concept that almost any colour can be composed of the three colours red, green and blue. blue. Black is displayed when the sum is 0, i.e. all LEDs are switched off, and White, when all LEDs are lit to the maximum. The secondary colours yellow, cyan and magenta are only mixed from two colours. Thus, for example, yellow is composed only of green and red and has the RGB value (255, 255, 0).

Farben anzeigen


Speaker

The Calliope mini can play music and sounds with its built-in piezo speaker. A Piezo speaker is based on the piezoelectric effect, derived from the ancient Greek piezein is derived, which means something like press or press. If the material is a When electrical voltage is applied, it deforms in the rhythm of the frequency. So can an audio signal from different frequencies are converted into sound waves. The same principle works also reversed as a microphone.

Eingaben / Input
Button - A, B, AB

Everywhere in our lives we find buttons that we need to press to perform actions and functions trigger, e.g. a PC keyboard, a game controller or the buttons on a vending machine. A button works much like a switch, except that it controls the circuit for so long closes as the button is pressed. The Calliope mini has two buttons: A and B. Simultaneously pressed, they can also result in a third input option:A + B


Touchpins - 0, 1, 2, 3

The touch pins are I/O input/output pins that are good for touching with your fingers close the circuit or apply alligator clips. There is a 6-cornered Calliope mini A total of four touch pins, numbered from 0 to 3, plus one plus and one negative pole Both the pins and the positive pole all feed a voltage of 3.3 volts. It is important the touching the negative pole to trigger a "pressing of the pins". All pins are digital. Pins 1 and 2 are also analog, with which e.g. servo motors are controlled or the analog values of a Potentiometers can output.

Sensoren
Motion and position sensor

The motion and position sensor (Bosch BMX055) contains a accelerometer, a gyro sensor and a magnetometer (compass). This allows the Calliope measure mini for example, in what position it is in and in what direction and with what force it is being moved.

Gestures

The different gestures with which the calliope is moved, shaken, etc. can be used as events in the respective programming environment.


Accelerometer

It can accurately increase or decrease speed using the accelerometer be measured. The values are given in thousandths of the acceleration due to gravity (g-force) and can be called up for the 3 axes x, y and z, as well as the total strength - this corresponds to the Sum of the G-force of all axles divided by the number of axles (3). Consider that the gravity always acts on us as an acceleration or attraction force and is also recorded by the accelerometer will.


Gyro sensor

With the gyroscope, the position or rotation of the two axes x and y can be measured in degrees (°). axes x and y can be measured in degrees (°). A rotation of the x-axis is called pitch and a rotation of the y-axis is called roll. A rotation of the Y-axis as rolling. If you place the Calliope mini on a table and draw a line between pin 0 and pin 3, then this is the this is the X-axis. Between the USB port and the opposite edge between pin 1 and 2, is the Y-axis.


Compass

The integrated magnetometer can measure the magnetic force of the earth's magnetic field and thus as a compass to serve. The cardinal direction is given in degrees (°). North is at 0°, East at 90° South at 180° and West at 270°.


Lightsensor

Light-emitting diodes (LEDs) can not only emit light, but also the light as photodiodes capture. The LED matrix of the Calliope mini is also the light sensor with which the Ambient light can be measured. This can cause differences in brightness be recognized by the Calliope mini between inside and outside or day and night. The brightness is output in the respective editor in a different value range. In Open Roberta in Percent 0 - 100 and in MakeCode in 8-bit from 0 - 255.


Temperaturesensor

A built-in temperature sensor is integrated in the processor (Nordic nRF51822), with which the Calliope mini can measure the approximate ambient temperature. The temperature is in degrees Celsius (°C) issued.


Microphone

The MEMS microphone can be used to measure the volume. It ranges from 0 - 100 percent.


Radio

The Calliope mini has a small antenna with which electromagnetic waves can be emitted and received. can be received. It supports two wireless transmission services: radio, which is used to transmit messages between different Calliope mini devices. messages are transmitted between different Calliope mini and Bluetooth, with which the Calliope mini can be paired with other devices such as mobile phones and tablets in order to transmit data or to be be programmed itself. Only one service can be activated at a time. It can be used via different radio groups/channels that are defined in the programming. Only Calliope mini of the same radio group can communicate with each other.

Send values

Numbers, texts and logical values (Open Roberta) can be sent. In MakeCode, a value pair can also be sent, which consists of a name and a number. and a number.

Receive values

The values can be received and retrieved if the Calliope mini is in the same radio group/channel. radio group/channel.

Befehle und Funktionen
Sequence

A sequence is the simplest form of instruction. The programme follows your instructions exactly from from top to bottom.

Start

The start function is included in every programme and is indispensable, because it defines what is to be executed once executed at the start of the programme and is something like the entrance and access to the programme. programme. As in a game or an event in real life, the rules and conditions for the programme sequence are also for the programme sequence are defined in advance in variables.


Break

When programming, pauses are important so that the computer lingers here for a short time. This can be important so that, for example, a colour display can be seen for a longer period of time before the programme is executed. However, the pause also suspends the entire programme for this period. If other tasks are to be completed during this period, e.g. a sound is to be played while the LED flashes in an interval, then it is recommended to use the runtime.


Loops

In programming, a loop is a control structure. It repeats statements infinitely long or until a termination condition is fulfilled.

Dauerhaft / wiederhole unendlich oft

The "infinite" loop ensures that an instruction is executed again and again. This is important in programming, so that certain sections of the code are executed permanently. For programming of continuous programmes without termination conditions, such as games, interaction projects or sensor measurements, interaction projects or sensor measurements, this block is usually indispensable.


Repeat x times

The instructions within the loop are executed as many times as specified.


Repeat while

The "Repeat until" loop executes an instruction until a termination condition is met. is met. A termination condition must be a truth value or a logical statement that can be true or false. can be true or false. An example would be to keep the LED flashing until the temperature drops below 10 deg. drops. "While" is the counterpart to "Repeat this long". The code is executed as long as the condition is true. "Repeat until" works in reverse. The code is executed again and again, while a condition is still false or has not occurred and aborted when it is true.


Repeat for index from to

This loop counts up an index for a defined value range and makes it available as a variable locally within the loop. variable locally within the loop. The loop starts at the start value and terminates when the highest value is reached. It suitable, for example, to count up a countdown with the value of the index or to retrieve values from a list. from a list.


Logic

The logic blocks are used to control a programme sequence and can lead to different outputs and results with different inputs. and can lead to different outputs and results when different inputs are made. The logic is based on Boolean algebra, in which two states/true values true and false or 1 and 0 are linked and lead to different outputs. outputs. Such logical operations form the basis for the transistor circuits in processors and digital electronics. in processors and digital electronics.

Logical/Boolean operators

There are logical operators such as negation (not), conjunction (and), disjunction (or) and Comparisons such as greater than(>), less than (<) and equal to (=). The logical operators can be used to truth values such as true and false can be returned.


Conditional statement

The conditional statement, known as the "if, then" or "if, do" block, guides a section only when a condition has been met. An example would be to turn on the RGB LED only when the temperature about 20 degrees rise. The LED stays red even if the temperature drops below 20 degrees again. A branch provides an alternative program section with "otherwise" that is performed, if the condition does not occur or is false. In the example of the LED you could use this once again turn off when it is below 20 degrees.


If, then / otherwise, if / otherwise

The second form of multiple branching can be thought of as a tree structure. It will be the first condition checked. If this is true, it goes to the next branch with the next condition. If this is false, the entire branch is aborted and the next conditions are no longer met checked. The order is crucial here. In the programming editors, several Conditions can be supplemented by clicking on the "+".


Math

A processor only processes two states 0 and 1 / on and off, but with the help of an on Arithmetic logic units (ALU) based on transistor circuits are used for arithmetic operations carried out in a jiffy. Thus, the Calliope mini can also be used as a pocket calculator in the decimal system and solve complex mathematical and logical tasks.

Arithmetische Operatoren

Mit arithmetische Operatoren wie Additon (+), Substraktion (-), Multiplikation (*) und Division (/) werden Zahlen zurückgegeben, die negativ oder positiv sein können und Nachkommastellen besitzen.


Modulo / Rest aus Division

Der Modulooperator (%) gibt den Rest einer Division aus zwei Zahlen zurück und kann hilfreich sein, um gerade Zahlen zu finden (i%2), ein wiederholendes Muster aus Zahlen zu generieren oder z.B. die X-Werte der LEDs in dem 5x5 Raster zu erhalten (i%5).


Random

A random number is chosen within a defined number range. The coincidence plays an important role in programming in games, but also in the encryption of data. In real life, if a dice was thrown, then the result is due to very many physical influences can hardly be predicted, although it would be possible in theory. Since computers work in a predictable (deterministic) way, i.e. always that after input desired result arises, in some cases by chance by entering physical, random data, such as key presses, ambient noise, location, etc. generated.


Variables

In programming, variables are a kind of "container" in which a program stores a data value, e.g. a number, a character string or a symbol. A variable can be queried and to be changed. For example, the score in a game is written to a variable and can can therefore be constantly queried and changed.


Lists

Lists are a data type that contain multiple numbers, text, logical values, or even images can. The values of a list can be processed and retrieved as a batch using loops will.

Werte hinzufügen

Werte können an eine Liste am Ende, am Anfang oder an der Position des Index hinzugefügt oder ersetzt werden.


Get Values

All values of a list can be retrieved and read out via the index with a loop.


Functions

Functions are something like self-defined program modules that are recycled and reused and with which a more complex program can be structured into subprograms. she can also be imagined as a machine which, as the word suggests, is a whole performs a specific function.

Function

A simple function just swaps the program code to another location and it can do so many times retrieved as the function is called (e.g. in a loop).


Function with input parameters

A function with input parameters is more flexible because you process different input values locally can and generates an individual output. E.g. a function for the blinking heart can be written and the number can be specified as a parameter, how often the LED should flash.


Function with return value

A function with a return value can be thought of as a machine that produces a product or manufactures an intermediate product. The return value is a data type, such as a number, a logical value, and can act as input again.