2021W1 – Lab 4: Synchronization

WEEK OF OCT 04

Learning Goals:

 Create a circuit which mimics the phenomenon of firefly flashing synchronization.

Pre-Lab:

Your firefly does three things:

  1. Activation: When your firefly reaches this point it is guaranteed to blink soon, even if it sees another light. This is where the times for the next activation and the LED are set.
  2. LED control: When your LED turns on and off.
  3. Light perception: Resets the activation timer when your firefly perceives another light.

Check out these slides if you get stuck (they are from the reading and our class on synchronization). Note that our version blinks every 3 seconds.

Look at this diagram.

Complete these questions before the lab:

It may be helpful to download the starter code and look at it in relation to the diagram.

Example: At time point θo, A, B , and θ2 are set.

  1. At time point C, _____ is set.
  2. At time point D, _____ is set.
  3. At time point θ1, ______, _____ , and ________ are set.
  4. At time point θ3, ______, _____ , and ________ are set.
  5. For a  firefly given stimulus 1, which boxes represent actual blinks?
  6. For a  firefly given stimulus 2, which boxes represent actual blinks?
  7. For a  firefly given no stimulus, which boxes represent actual blinks?

Lab:

Part 1: Programming your own firefly

  • GOAL: Get your LED to blink and reset according to the pre-lab.
    • Make a circuit with 2 photoresistors and a LED.
      • Make sure your photoresistors are aligned with each other!

Direct link to code

 

  • Find all the places marked with an TO-DO and code those spots.
  • Refer back to the diagrams if you get stuck.
  • Show the TA when the light works.

Part 2: Synchronize your fireflies

Now you can start actually synchronizing your fireflies. You may need to take measurements and adjust thresholds for each firefly agent if you are using different valued resistors. You should be able to get the fireflies to synchronize in the light of the room, but if you want to make them look cool, we can put them in a dark place that the TAs will set up.

  • GOAL: Get your firefly to synchronize within your group.
  • GOAL: Get your fireflies to synchronize with another group.
  • Show the TA your fireflies synchronize.

Part 3: Grand Synchronization

At one point, the TAs will ask everyone to synchronize their fireflies. They’ll turn off the lights and see what we can get to work. You can go to Part 4 while you wait, but keep your fireflies assembled.

Part 4: Get creative

Now that you’ve learned how to synchronize large groups of agents, can you start to influence their behaviour? Come up with a creative paradigm for controlling the fireflies. For example, can you introduce a firefly that “controls” all other fireflies? Can you create alternative patterns? Can you speed up synchronization? Brainstorm with your group to try something fun. Post to the Discord.

Optional Challenge: Synchronize something else

If you’re still looking for something to challenge you—first, wow! Now that you’ve seen working LED light synchronization scheme, can you get something else to synchronize? For example, can you get two servo motors to coordinate their movements? Try designing a simple synchronization scheme using other components such as servos. You may want to continue to use photoresistors and LEDs as a way to coordinate.

Common Debugging problems

  • Make sure your photoresistors are in parallel
  • Use a lot of print statements