viernes, 25 de octubre de 2013



/* Some arduino experiments */


I´m working with some friends to make a portable videogame console, based on OMAP4 (arm cortex-a9 and SGX540 gpu), with Arduino as input, and Android as SO ( I would like to use linux arm, but Unity it´s not available for this platform).

The first test are playing with the arduino, we have two arduino UNO and a ESPLORA board. We would like to make our own PCB with gyro/accel two joysticks and other things like vibrator, but the ESPLORA board is a really good one to start with.

There are three phases:
a) program Arduino board
b) program a SerialPort library
c) program a Unity plugin for using the arduino.

The work is done, but it was more difficult than expected...

a) You have to program the arduino board to spit all sensor states (joystick and switches for example), while program the arduino to receive commands, both things from serialPort.

b) You can write a small C/C++ for desktop platform (windows/linux/mac x86) program to ensure you arduino sketch works as spected; ok, the terminal is showing the arduino´s vomit (I mean, the input values).

Now, encapusle the library into dll file, and create some static functions and variable in order to use on c# (Unity3d)

c)StringBuilder works in editor, not in builds...

After learning how to connect a in/out variable (the buffer of the serialPort, char* ) from c to c#, we have unity showing the arduino´s vomit too (cool). But it shows corrupt data.
casting from byte[] and char[] solve the corrupt data (uff).

Now all work is a joke:

Connect/Disconnect the serial port, if you don´t release the serail port correctly, you will have problems

SerialPort has some errors, we have to imlement some kind of checksum to ensure the line you are reading from buffer is complete and valid.
Sync arduio output with unity it´s not easy, and it´s not good, because I would like to make the library FPS indpenent, so, modify the code to read much quickly than arduino, and much slowly than arduino.
Lag appears, lag go far away XD

And we can change the RGB LED from unity if you are near a light for example. Now the Explora is working really good ;)


No hay comentarios:

Publicar un comentario