A Cheap Serial Based TTL Device

From Center for Cognitive Neuroscience
Revision as of 20:20, 27 February 2013 by Crodriguez (talk | contribs)
Jump to navigation Jump to search

Hardware/Parts:

Software/Downloads:


To Initialize the Arduino Box: if DAQ == 1

  if IsOSX == 1
      if (exist('DIO', 'var') == 0)
               % the exact address can be figured out using http://arduino.cc/en/Main/Software 
               DIO = arduino('/dev/tty.usbmodem621');
       end
       for i = 2:19
           DIO.pinMode(i,'output');
           DIO.digitalWrite(i,0)
       end
       else
           DIO = digitalio('nidaq','1');
           addline(DIO,0,'out');
           putvalue(DIO,0);
       end

else

   DIO = [];

end

To Send a pulse:

TTLpin = 2; % any pin from 2 through 19 can be used DIO.digitalWrite(TTLpin,1); % set pin to 5V wrt to GND DIO.digitalWrite(TTLpin,0); % set pin to 0V wrt to GND


To close the session delete DIO;