To program easily some components we use with the arduino-based 4in1 board we need to add libraries to our programming software, so we can “talk” with them.

Here you will find a quick guide how to add libraries required for each component according to the software you want to use, mBlock for block programming, and Arduino IDE for code:

RGB Neopixel LED

1. Component and library needed

The RGB modules used in ebotics kits have an adressable chip, the WS2812, called usually neopixel. With these type of leds strips we can assign different parameters to each LED with only one digital output.

The library we use to control these leds with mBlock 5 is called NeoPixel from Robokacija. There is also a version 2, we use the first one.

2. Adding library to mBlock 5

We search “Neopixel” in the mBlock extension center, then download it if is the first time we use it pushing the “plus dot” in top right corner, and finally click on “+ Add” to use in current project.

3. Using new library blocks

Two new blocks are available inside group NeoPixel:

  • INITIALIZE PIN 3 for 1 LEDS: Must be in first part before any loop, to initialize the component library, specify wich pin is conected, and how many leds are in strip. In our board there is only one led.
  • SET LED nr. 0 STRIP TO R[] G[] B[]: Use this block any time you want to change color or state in your led. Using one led, always will be number 0, and set a value between 0 and 255 for each colour channel, RED, GREEN, and BLUE, to get any colour.

1. Component and library needed

The RGB modules used in ebotics kits have an adressable chip, the WS2812, called usually neopixel. With these type of leds strips we can assign different parameters to each LED with only one digital output.

The library we use to control these leds with Arduino IDE is called Adafruit NeoPixel. It can be installed searching “Neopixel” in the Library Manager.

2. Adding library to Arduino IDE

Open Arduino IDE software. Go to “skecth” menu -> Include library -> Manage Libraries. Then search “neopixel” and click “Install” button on Adafruit NeoPixel by Adafruit.

3. Using library

You can find sample programs going to “File -> examples -> Adafruit neopixel“.

In our program, first at all, we need to include library and create a neopixel object (sirena) defining number of leds in strip (1) and output digital pin (6) :

#include <Adafruit_NeoPixel.h>

Adafruit_NeoPixel sirena = Adafruit_NeoPixel(1, 6, NEO_RGB + NEO_KHZ800);

Then, inside setup() code we initialize the neopixel object:

void setup() 
{
  sirena.begin();
  sirena.show();
}

Finally we can change color RGB status when we want inside loop code with setPixelColor(LED NUMBER, RED , GREEN , BLUE ) and apply changes with show():

    sirena.setPixelColor(0, 0, 255, 0);
    sirena.show();

You can find more details about this library in their website

I2C LCD Display

1. Component and library needed

Our LCD display communicates throught I2C serial port. The library we use to control it with mBlock 5 is called LCD i2c by vn-nda. 

2. Adding library to mBlock 5

Search “i2c” in the mBlock extension center, find the library LCD i2c by vn-nda, download it if is the first time you use it, pushing the “plus dot” in top right corner, and finally click on “+ Add” to use in current project.

3. Using new library blocks

Now you find new blocks available inside group LCD i2c:

  • Turn on LCD at address [0x27] with [2] lines and [16] characters/line: Must be in first part before any loop, to initialize the component library. The default values are right. No need to change them.
  • All the other blocks are used inside your program, and are self explanatory. Try them!!

1. Component and library needed

Our LCD display communicates throught I2C serial port. The library we use to control it with Arduino IDE is called LiquidCrystal I2C. It can be installed in the Library Manager.

2. Adding library to Arduino IDE

Download the libary, then open Arduino IDE software. Go to “skecth” menu -> Include library -> Manage Libraries. Then “add zip” and search the downloaded file.

3. Using library

You can find sample programs going to “File -> examples -> LiquidCrystal_I2C“.

In our program, first at all, we need to include libraries needed and create a lcd object

#include <Wire.h> 
#include <LiquidCrystal_I2C.h> // LIBRERIA PARA LA PANTALLA LCD

LiquidCrystal_I2C lcd(0x27, 16, 2); // CONFIGURACIÓN DE LA PANTALLA LCD

Then, inside setup() code we initialize the neopixel object:

void setup() {
  lcd.begin(); // INITIALIZE LCD
  lcd.clear(); // CLEAR LCD
}

Finally we can write characters in any position in display or clear all:

  lcd.setCursor(0, 0);  // Start write in column 0 line 1
  lcd.print("Hello world");  //Text output
  lcd.clear(); // CLEAR LCD

If you have any issue, you can contact us for support.