Mindstorm Firefly Synchronization:
The goal of this project is to create a firefly synchronization program for NQC that is based on the code from the StarLogo program. The program models firefly emergent synchronization: large numbers of independent fireflies that gradually grow to blink in sync. There are several online implementations, but I was curious as to the possibility to recreating the phenomenon using real world lights and sensors.
Contexts
* Firefly lanterns as a community project for Vancouver's Illuminares festival
* Goddess lanterns (using emergent synchronization in allusion to a woman's
menstral cycle)
* Peace lanterns (independent voices merging together in one voice)
Code
Version 1.0, Firefly
//
This program is based on the star logo logo code for
// synchronous flashing of fireflies
// firefly.nqc
int
thresholdE; // level at which excitement reaches point of no return
int speedProg; // speed at which the program runs
int lengthProg; // length of program run -- personalization
#define Flash OUT_A
#define light1 SENSOR_1
task main(){
ClearCounter(1); // Counter(1) = excitement level (increments according to speedProg speed)
SetSensor(light1, SENSOR_LIGHT);
SetSensorMode(light1, SENSOR_MODE_RAW);
speedProg = 50; // can be random as well-- a personalization variable
lengthProg = 14;
while (true){
thresholdE = (Random(10) + 5); // in long term, a percentage of lengthProg
if (Counter(1) > lengthProg){
OnFor(Flash, 50);
ClearCounter(1);
}
IncCounter(1);
if (Counter(1) > thresholdE){
if (light1 < 550){
PlaySound(SOUND_CLICK);
OnFor(Flash, 50);
ClearCounter(1);
}}
SetUserDisplay(Counter(1), 0);
Wait(speedProg); // space out increments (slow down, speed up)}
}
Prototype
Images of the test brick forthcoming.
References
StarLogo Sample Projects - Firefly