Channeling imagination

The Arduino Designer: an Eclipse programming platform for kids

Children are curious by nature: they explore, question, wonder, and by doing so, learn. From the moment of their birth, likely even before, humans are meant to learn new things. When we are curious about something new, we want to explore it.

A good way to discover is to explore by yourself, trying, working through successes and failures. In this way, kids learn causes and effects.

Today, the world is made of computers. At home, in TVs, DVD players, coffee machines, electronic toys, pet robots, cars, planes, phones...the list is endless. Nowadays kids are used to playing with tablets and computers. They are curious to understand how a video game is created, how computers work and all about anything electronic.

In our connected world, one of the things kids have to learn is electronics. The idea of learning electronics for them is mostly to understand that they can use sensors to listen to the environment and actuators with which they can interact. We expect that they understand that these modules are connected to a platform which contains software.

Open Hardware

The problem with electronic devices is that most of the time they are composed of very tiny components, which are not easy to be manipulated by kids. It is also very easy to make a bad connection and damage your electronic module or component.

LittleBits is an open source library of electronic modules that snap together with tiny magnets. There is no soldering, no wiring, and no programming required. The devices is really great for helping to foster an understanding of electronics without any programming knowledge, and to make kids perceive and grasp the connection between software and hardware modules.

Nowadays, it is really easy to get good material to learn electronics thanks to the open hardware initiative. The most famous open hardware platform is Arduino. With Arduino you get a piece of hardware, but also documentation and a development environment that fits together with the hardware.

The Arduino board is like a small computer that can be programmed as often as needed. As a computer, it provides I/O interaction, through digital and analog pins. Arduino can sense the environment by receiving input from a variety of sensors and can affect its surroundings by controlling lights, motors, and other actuators.

The microcontroller on the board is an Atmel AVR microcontroller and is usually programmed using the Arduino programming language and the Arduino development environment. In fact, the Arduino language is just C++ using a specific Arduino library and syntaxic sugar that makes it much easier than normal C++.

What's great about Arduino is that it is cheap and really easy to find. There are many efficient providers available online, for example AdaFruit, DFRobot, SeeedStudio, and SnootLab. They provide an incredible amount of modules! Order and two days later you will receive your new toy at home.

Learn programming

Programming is all around us! For this reason, to fully understand our world, our kids also have to learn coding. Many different initiatives are arising to teach programming to kids: Programatoo, Devoxx4Kids, Greenlight, Coding Goûter, either based on open source software or proprietary software. The most famous, TurtleLogo is for the older ones. More recently, Scratch has become more popular. These tools use different approaches to teach programming.

In TurtleLogo kids write text to move a small turtle cursor in order to draw shapes. No graphical UI, very simple language. They learn the concepts of programming and understand that a program is just a sequence of instructions.

In Scratch you drag and drop elements from a palette to animate a character. This tool is a complete IDE which allows kids to create cartoons, video games, movies and provides a more graphical UI. Kids have to assemble puzzle pieces which are instructions to describe a program.

These tools are great to learn what programming is. There are other kinds of tools that allow kids to program the real world by interacting with sensors and actuators. Open source tools like Scratch4Arduino or Ardublock provide UIs for simple programming of the Arduino platform. Thanks to these tools, kids can develop a small program, upload and run it on hardware platforms and so interact with the real world.

Simplified Eclipse for kids

Eclipse is one of the most famous IDEs, with millions of users all over the world. So we could imagine that kids could use it also to learn programming. But if we give them the original Eclipse IDE, the UI and the default available languages (such as Java or C) are too complex for kids to discover programming.

Arduino Designer is born from our desire to give kids a tool to code the real world and from our aspiration to make Eclipse accessible to them. The idea was to develop a new software to allow kids to create small programs for Arduino.

Our first action was to simplify the Eclipse UI, the project lifecycle and to provide a graphical block language to be able to develop simple programs and run them on electronic modules. The purpose is to provide a simple dedicated tool which gives the possibility to discover the effects a software program can have on electronic modules.

The UI of the Arduino Designer defines no menu, just one toolbar with 4 different buttons to : manage the project, define the hardware modules used and to define the software that would be uploaded on the hardware platform.

A dashboard helps children by indicating what is the next step in the development process. There are three steps to follow:

  1. Describe the hardware platform and the connected hardware modules: the child must define the hardware platform they are using and the different sensors and actuators he connects to the Arduino. This is done by defining platforms, modules and wires thanks to the tools available in the palette of the Hardware representation.

  2. Describe the software: Kids write the sketch (in Arduino speak, a program) that describes the behavior that the hardware platform should have. This description is done using a simple graphical block-based language. With this graphical language, it is possible to create instructions like while, repeat or if instructions, which introduces kids to the basic control structures of most programming languages. It is also possible to use functions like delay, to reference hardware modules, to create variables and constants and use some mathematical operators. The language included in the first prototype remains close to the text-based Arduino language, providing a direct connection between the graphical representation and the textual representation of a program.

  1. Upload the software to the target: And finally, to run the software on the hardware platform, the user simply has to upload the sketch to the target thanks to the upload button available in the toolbar or from the dashboard.

Sirius

The Arduino Designer is based on Sirius, a new project in Eclipse to quickly define multi-view workbenches based on DSL with dedicated representations.

During the prototype development phase, Sirius allows to quickly develop a specific modeler dedicated to Arduino. The development is easy, dynamic and iterative thanks to a live preview. For the kids, they get a tooling completely adapted to the development of small Arduino projects and simple to use.

  1. Define the language: To use Sirius to create the designer, we started by representing the Arduino language as an ecore metamodel.

  2. Specify representations: Second step, we specified the different representations: Dashboard, Hardware, Sketch. Then we mapped the different concepts defined in the metamodel to graphical elements and defined the tools provided by the designer palettes for each representation.

  1. Write generator: Next step was to develop a small generator with Acceleo to generate the Arduino sketch from the model.

    The generator creates .ino files for sketches identical to the one usually manually written with the Arduino IDE. As the Arduino language is based on C/C++, it links against AVR Libc and allows the use of any of its functions. The AVR Libc package provides a subset of the standard C library for Atmel AVR microcontrollers like Arduino.

  1. If we look at the generated code, we can see that Arduino programs are divided in two main parts. The setup() function is called when a sketch starts. It is used to initialize variables, pin modes, start some libraries, etc. The setup function will only run once, after each powerup or reset of the Arduino board. After generating the setup() function, the generator creates a loop() function. This function is called in an infinite loop, and is therefore used to implement the behavior of the system, typically read data from sensors, decide what to do, and perform actions using actuators.

  2. Cross compile code for the target: When you use the Arduino environment the compilation and upload actions are directly integrated. Here we integrate the generation and the compilation of .ino files in the Arduino Designer which is an Eclipse application. The generated files are compiled using avr-gcc which is a cross-compiler for the AVR chip that runs the Arduino. After building, a new directory has been created which contains all the object files.

  3. Upload the sketch on the Arduino platform: Then the upload action from the toolbar simply upload the software on the target by using avrdude. avrdude is a very handy utility for loading code into AVR microcontrollers. As Arduino ships with its own bootloader, it is possible to load and run code using only a single USB cable connecting the computer to the board. Usually this cable comes with the Arduino kit. The kids using the Arduino Designer do not see any of these steps as they are all integrated in the upload action.

Code and Examples on github

The code is available under EPL license on github: http://github/mbats/arduino

In this first prototype, we provide the hardware components included in the DFRobot Ardublock kit which contains: ambient light sensor, infrared sensor, sound sensor, push buttons, rotation sensor, servo motors and we also support a fan. We also provide some example sketches.

As usual with a new language, the first example developed was the “Hello world” sketch and as we are programming hardware components, it consists in blinking an LED.

int brightness;

void setup() {

brightness=0;

}

void loop() {

while ((brightness<255))

{

brightness=(brightness+1);

analogWrite(11,255-(brightness));

delay(8);

}

while ((brightness>1))

{

brightness=(brightness-1);

analogWrite(11,255-(brightness));

delay(8);

}

delay(200);

} 

As explained before, on Arduino the main program is just an infinite loop. So the sketch will be valid only when the loop will be closed. What we have to do to make an LED blink? What does it mean? It just means switch the LED “on”, then keep it powered during a certain time, after switch it to “off” and keep it like this during a certain delay and loop.

The second available example demonstrates how to use sensors. From the hardware point of view, we need to connect an LED and a pressed button. The following sketch references an LED and connects it to a push button in order to switch on/off the LED according to whether the button is pressed or not.

Other examples demonstrate how to use the loop instructions, the variables and mathematical operators, for instance to change the brightness of an LED in order to get a fading light.

As you can see the Arduino Designer allows to develop really simple projects. But thanks to these different simple functions we are able to build more complex projects. One thing that kids and adults enjoyed quite a bit is creating robots. So we also provide a tutorial to create an electronic cat based on high tech composite materials coming from trash cans, made out of cardboard and lots of scotch tape.

 

  

The cat can:

  • Feel when you push its nose button, at which point it will switch on its flashing necklace.

  • Detect something close to its eyes, which will operate its servo-motored tail.

  • Hear sound, which will start its bubble machine. The bubble machine is composed of a servo that controls the bubble stick and a fan.

Join us and contribute

It is really easy thanks to Sirius to create specific designers, you can have a look at the Sirius website to get more detailed information about the principles of Sirius :http://www.eclipse.org/sirius.

Go to github to get the Arduino Designer code and examples, clone it and contribute! We will be happy to integrate your code for the modeler, other application examples, tutorials, documentation – anything you need.

Mélanie Bats

Mélanie Bats works as a software developer at Obeo. In her daily work, she is mainly focused on the development of modeling tools with Sirius (UML Designer/SysML Designer). In her free time she is interested in Arduino stuff and contributes some Eclipse plugins for cross compilation. She is also a free software activist who has organized and participated in free software events in the Toulouse area.

Mélanie Bats

What do you think?

JAX Magazine - 2014 - 05 Exclucively for iPad users JAX Magazine on Android

Comments

Latest opinions