Close

Manipulating the code for the laser set-up

A project log for The Dragonfly: Nature's Guided Missile

Examining the neural activity of dragonfly predatory behavior to discover the mechanics of its highly accurate prey capture

patricia-aguiarPatricia Aguiar 07/11/2016 at 05:340 Comments

In order to replicate Paloma Gonzalez-Bellido's experiment, I need to be able to manipulate the direction and position of the laser beam. In Paloma Gonzalez- Bellido's 2012 paper she publish these results:

Gonzalez-Bellido, P. T., H. Peng, J. Yang, A. P. Georgopoulos, and R. M. Olberg. "Cozzarelli Prize Winner: Eight Pairs of Descending Visual Neurons in the Dragonfly Give Wing Motor Centers Accurate Population Vector of Prey Direction." Proceedings of the National Academy of Sciences 110.2 (2012): 696-701. Web.

The diagrams on the left column plot the preferred direction of a certain neuron (labeled DIT.., MD... etc). Imagine that in the centers of the circles are the dragonflies, and that each color represents a position the target could be moving in. The red arrow points to the position that is preferred. The next column represents the flattened out screen. Each colored dot represents a pixel that the target has either started or passed through, and each color represents the direction. By looking at the left column, we can determine the direction the target was moving. The last column represents the firing rate- yellow being the greatest and black being the weakest.

I wrote a first draft of code, using Arduino, to mimic the experiment. Using the data collected about the preferred direction and the preferred starting location of the target, I designed code that would move the laser beam from each of the preferred starting locations for each of the neurons and travel in each of the neurons preferred directions.

For example, I wrote code for the neuron MDT3:

#include <Servo.h>
  
  const int servo = 10;       // The servo motor pin
  const int servo2 = 11;
  int laserPin = 12;
  Servo myservo;  // create servo object to control a servo
  Servo myservo2;
  int servoAngle= 0;
  
  void setup() {
  
    // Servo  
  pinMode(laserPin, OUTPUT); // set up the laser pin
  
    myservo.attach(servo);  // X servo
    myservo2.attach(servo2); // Y servo
  

  }
  
  
  void loop(){
    
    for (int i = 0; i < 11; i ++)
    {
    
    for (int j =0; j < 5; j ++)
    {
      
    digitalWrite(laserPin, LOW);
     
      myservo.write(30); // X servo starting point
      myservo2.write(60 - i*(2.5)); // Y starting point - moves with i
      delay(100); // 100 millisecond delay
      digitalWrite(laserPin, HIGH); // turns the laser on
      for(servoAngle = 30; servoAngle < 55 ; servoAngle ++)
    {    
      myservo.write(servoAngle); // X servo moves

       delay(50);
    
    }
    }
    
    delay(1000);
    }
  
  
  }
 
The result is:

Here is the first draft of the code for the final testing:

#include <Servo.h>
  
  const int servo = 10;       // The servo motor pin
  const int servo2 = 11;
  int laserPin = 12;
  Servo myservo;  // create servo object to control a servo
  Servo myservo2;
  int servoAngle=0;
  
  
  void setup() {
  
    // Servo  
  pinMode(laserPin, OUTPUT); // set up the laser pin
  
    myservo.attach(servo);  // attaches the servo to the servo pin
    myservo2.attach(servo2);
  
    // Inizialize Serial

  }
  
  void loop(){
    
    //DIT1
    
    for (int i = 8; i < 11; i ++)
    {
    
    for (int j = 0; j < 5; j ++)
    {
     
     
      myservo.write(55);
      myservo2.write(60 - i*(2.5));
      delay(100);
      digitalWrite(laserPin, HIGH); // turns the laser on
      for(servoAngle = 30; servoAngle >10 ; servoAngle --)
    {    
      myservo.write(servoAngle);

       delay(50);
    
    }
    digitalWrite(laserPin, LOW);
    delay(2000);
    }
    delay(10000);
    }
    
    //DIT3
        for (int i = 0; i < 11; i ++)
    {
    
    for (int j =0; j <5; j ++)
    {
      

     
      myservo.write(55);
      myservo2.write(60 - i*(2.5));
      delay(100);
      digitalWrite(laserPin, HIGH); // turns the laser on
      for(servoAngle = 45; servoAngle >20 ; servoAngle --)
    {    
      myservo.write(servoAngle);

       delay(50);
    
    }
       digitalWrite(laserPin, LOW);
    delay(2000);
    }

    
    delay(10000);
    }
    
    //MDT1
        for (int i = 0; i < 11; i ++)
    {
    
    for (int j =0; j <5; j ++)
    {
      
  
     
      myservo.write(55);
      myservo2.write(60 - i*(2.5));
      delay(100);
      digitalWrite(laserPin, HIGH); // turns the laser on
      for(servoAngle = 55; servoAngle >20 ; servoAngle --)
    {    
      myservo.write(servoAngle);

       delay(50);
    
    }
       digitalWrite(laserPin, LOW);
    delay(2000);
    }

    
    delay(10000);
    }
    //MDT5
    
        
    for (int i = 0; i < 11; i ++)
    {
    
    for (int j =0; j <5; j ++)
    {
      
 
     
      myservo.write(20);
      myservo2.write(60 - i*(2.5));
      delay(100);
      digitalWrite(laserPin, HIGH); // turns the laser on
      for(servoAngle = 20; servoAngle < 55 ; servoAngle ++)
    {    
      myservo.write(servoAngle);

       delay(50);
        
    }
       digitalWrite(laserPin, LOW);
    delay(2000);
    }
    
    delay(10000);
    }
    //MDT3
        for (int i = 0; i < 11; i ++)
    {
    
    for (int j =0; j <5; j ++)
    {
      
      myservo.write(30);
      myservo2.write(60 - i*(2.5));
      delay(100);
      digitalWrite(laserPin, HIGH); // turns the laser on
      for(servoAngle = 30; servoAngle < 55 ; servoAngle ++)
    {    
      myservo.write(servoAngle);

       delay(50);
    
    }
       digitalWrite(laserPin, LOW);
    delay(2000);
    }
    
    delay(10000);
    }
    
    //DIT2
        
    for (int i = 0; i < 11; i ++)
    {
    
    for (int j =0; j <5; j ++)
    {
      
      myservo.write(30);
      myservo2.write(60 - i*(2.5));
      delay(100);
      digitalWrite(laserPin, HIGH); // turns the laser on
      for(servoAngle = 30; servoAngle < 55 ; servoAngle ++)
    {    
      myservo.write(servoAngle);

       delay(50);
    
    }
       digitalWrite(laserPin, LOW);
    delay(2000);
    }
    
    delay(10000);
    }
    
    //MDT2
        
    for (int i = 0; i < 11; i ++)
    {
    
    for (int j =0; j <5; j ++)
    {

      myservo.write(30);
      myservo2.write(60 - i*(2.5));
      delay(100);
      digitalWrite(laserPin, HIGH); // turns the laser on
      for(servoAngle = 30; servoAngle < 45 ; servoAngle ++)
    {    
      myservo.write(servoAngle);

       delay(50);
    
    }
       digitalWrite(laserPin, LOW);
    delay(2000);
    }

    
    delay(10000);
    }
    
    //MDT4
        
    for (int i = 0; i < 11; i ++)
    {
    
    for (int j =0; j <5; j ++)
    {
      
      myservo.write(50);
      myservo2.write(60 - i*(2.5));
      delay(100);
      digitalWrite(laserPin, HIGH); // turns the laser on
      for(servoAngle = 50; servoAngle > 20 ; servoAngle --)
    {    
      myservo.write(servoAngle);

       delay(50);
    
    }
       digitalWrite(laserPin, LOW);
    delay(2000);
    }

    
    delay(10000);
    
    }
  }
  

Discussions