Amy’s Microtome Counter

Yesterday something awesome happened: Amy (one of the other postdocs in the lab) came to me with an idea for a piece of kit that would help her in the lab. She found that when she was cutting brain sections on the microtome, she would sometimes zone out and forget which plate she was up to. Her request was for a microtome section counter.

The idea was to have something that would light up an indicator of which plate she needed to put the next section into. It would also require a sensor of some kind that would be activated each time she placed a section. We quickly came up with a workable idea that would use an IR sensor, and the user would sweep their hand close to the sensor after each brain section was added.

This project is just asking for an Arduino, so first thing I did was sketch out some code:

// Specify pin connections
int IR = 2;
int LED1 = 3;
int LED2 = 4;
int LED3 = 5;
int LED4 = 6;
int toggle = 7;

// Specify other variables
int count = 0;            // Counter
int maxcount = 4;         // Number of plates to count
long delayTime = 500;     // Delay time to prevent multiple activations
long lastTime = 0;        // Time stamp from last activation

void setup() {

// Specify pin setup
pinMode(IR, INPUT_PULLUP);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(toggle, INPUT_PULLUP);

}

void loop() {

// Toggle to select number of plates being used
if(digitalRead(toggle) == LOW){
  maxcount = 3;
}
else{
  maxcount = 4;
}

// Detection by IR sensor 
if (digitalRead(IR) == LOW){
  if(millis() - delayTime > lastTime){    // Have you exceeded time since last activation?
    count++;                              // Add to counter
    lastTime = millis();                  // Specify timestamp of IR activation
  }
}

// Overflow counter back to start
if (count >= maxcount){              
  count = 0;
}

// Switch on each LED in turn depending on counter
if(count == 0){
  digitalWrite(LED1,HIGH);
  digitalWrite(LED2,LOW);
  digitalWrite(LED3,LOW);
  digitalWrite(LED4,LOW);
}

if(count == 1){
  digitalWrite(LED1,LOW);
  digitalWrite(LED2,HIGH);
  digitalWrite(LED3,LOW);
  digitalWrite(LED4,LOW);
}

if(count == 2){
  digitalWrite(LED1,LOW);
  digitalWrite(LED2,LOW);
  digitalWrite(LED3,HIGH);
  digitalWrite(LED4,LOW);
}

if(count == 3){
  digitalWrite(LED1,LOW);
  digitalWrite(LED2,LOW);
  digitalWrite(LED3,LOW);
  digitalWrite(LED4,HIGH);
}

// Reset timer overflow
if(millis() - lastTime < 0){
  lastTime = millis() - lastTime;
}

}

The electronics is fairly straightforward:

Amy's microtome section counter schematic.

A small amount of assembly later, and we had a working prototype:

Microtome sectioning counter
Amy’s microtome counter

Amy has promised to test it. I’ll let you guys know how it goes.

Leave a Reply

%d bloggers like this: