This code has two loops, sense and shine. In shine, the IR LED blinks on and off really really fast. In sense the led is off and the sensor (an IR photo transistor) is read at the rate of LED blinking. Then there is a debouncing algorythem.. or a more apropriatly rebouncing algorythem that makes sure each sensor value alternates being higher or lower than the previouse sensor value. When this is the case some number of times in a row, another led blinking has been detected. When blnking is detected the counter that defines the lengeth of the loop is multiplied by 1.1 casuing the sense loop to end sooner untill the LEDs are in sync. Currently the design works on an arduino at a range of 2' to 4' in a dimly lit room.
Things to do:
optimize for low power consumption
figure out how well this will work with more than 2 fireflys
more percise timing may be accomplished with interupts
add an asyncronus loop that makes a green LED fade in and out in phase with the other loops
add a function to sleep during the day
design final board
spec final components
add a phase locking mechansism to compensate for clock drift.
Usefull links:
programing the attiny10
http://www.technoblogy.com/show?1YQY
http://junkplusarduino.blogspot.com/p/attiny10-resources.html
Attiny10 Datasheet
grant proposal
https://docs.google.com/document/d/1ZPEneeNdc6gHhQVbn35usS5zam0JfSeI3uuNZ7ygSEo/edit?usp=sharing
Photo transistor schematic
project insperation