WEEK 14 | Interface & Application Programming
This week I worked on an interface that would track the marble position on the Colabyrinth. Just to remind you: 36 LEDs and switches will be spread all over the maze (a switch per LED).
On the interface every "star" (flashing white point) matches an LED position on the table. When the marble closes a switch, the star associated to this switch stops blinking. Some lines appear and draw the marble itinerary.
Simulation on Processing
I started the week by designing the interface (because it's much more fun). I had to create the FlashingSphereClass. Each star has many parameters (position, identity, etc.). One of those parameters is called "state". When "state" equals 1 that means that the marble closed the according switch. The lines are created between the stars with a state equal to one.
You'll find the processing code here.
This tutorial helped me with the flashing effect.
Processing, Arduino library & Firmata
I first tried to use the Arduino library in Processing and Firmata. All the code was written in Processing. I just uploaded StandardFirmata sketch from Arduino to my board. It wasn't working so I used the oscilloscope to check the communication. This is the signal I got (picture above). Actually it was the Serial signal because I was using RX and TX pins to connect the switch matrix.
After a while working on this code and not making any progress, I decided to switch to the Serial option.
If you wanna try Firmata option, visit this page and download the library for Processing.
Here is my Processing code.
Processing, Arduino & Serial
In this code Serial is sending data to processing as Strings. And in order to communicate with Processing I needed to read the three integers in each string. Daniel told me about the split() function.
Here are my final Processing code and Arduino code.
This is a link to a Processing code for a 2x2 pressure matrix (GitHub).
This the data used to communicate.
Final project electronic design - Test
I also used this week to test the electronic design of my table: the circuits (LED & switch) and how to embed it into the wood. I see more clearly what I could do now. And it won't be this design: risky and complicated for nothing. I realised that I don't need to place the switches and the LEDs at the same place which makes it much easier. I would also prefer not to have to flip the sheet of wood even if I got very great advices from my fabmates.
Switches matrix drawing
This week I just tested the interface with two switches (1X2 matrix). The idea was to create a program that works with bigger matrices (6x6 for the marble game).