Monthly Archives: May 2013

Going to Arduino from C#, Java, …

So far I have spent several hours programming Arduino. It has been a very pleasant experience, because, as for many other programmers, seeing things changing behaviour after your code is an exciting sensation. Usually you just see something happening on the screen.

Anyway, first times were sometimes hard: Arduino seemed sometimes doing weird things: stopping, ignoring your code, and so on.

Arduino is programmed in C (ok, C++ if you prefer, at least in theory). As a friend of mine says: “C is well-camouflaged assembler”. So, if you are coming from languages like Java, C#, FORTRAN, Python you likely are not used to think about, for example, array length, You create new arrays, delete them, assign them to variables without any trouble. You don’t know that here in C language everything can hide a trap. In short, arrays are not dynamically managed: you must take charge of their dimension. For instance, if you write:

char arr[2];
arr = "abcdefg";

your code compiles smoothly… and at runtime your last letters will go wandering lost in space somewhere… but surely where they are not allowed to 😉