Skip navigation

Code

code1.jpg

In order to avoid unwanted surprises the team has been working on 2 different prototype versions, that we defined simulation and prototype:
- in the first, the projector has been used to project 15 light dots on 15 photoresistors placed on the wall.
- in the second - not far from the real installation - the projector has been used only to simulate the sun lighting up 3 round mirrors moved by servo motors which were reflecting light on 3 photoresistors.


Simulation

prototype.jpg

In processing a grid of 15 dots has been coded; the Y value of each dot changes with a sin() function, triggered by a char value coming from Arduino, that is sent everytime that the state (high/low) of the relative photoresistor changes.
Indeed, in Arduino only 2 conditions for each photoresistor were set: if someone covers the light projection, the sensor passes from a state 0 to a state 1 otherwise it remains on state 0. Every time the state is set on 1, Arduino sends a different letter (a, b, c, d, e, f….w, z, etc.) as a char value to Processing, as explained before.

NB: code files are fully commented to guide the user step by step


Prototype

You need to a flashplayer enabled browser to view this YouTube video

The Prototype code - made in Arduino software - differs from the one of the Simulation only for the setting of servo motors that are controlling the round mirrors. Also in this case a sin() function is used to create a smoother movement for both light projections and state conditions. If the light projection is interrupted the state goes from 0 to 1 and the servomotor gets activated and moves the light dot up and down the wall till the photodetector is hit once again by the light.

NB: code files are fully commented to guide the user step by step