This simple optogenetics stimulation driver is based on the Arduino Mega, and produces millisecond-accurate timing to control up to 4 lasers or LED's. The dials allow easy control of pulse on-time and frequency, with simple switches to independently turn the flashing on or off for each output.
This pulser can be used to control lasers or LED's for in vivo or in vitro optogenetics stimulation.
The code is written for a wide range of preset timings, but can easily be modified prior to uploading to the Arduino.
Files
EasyTTL_mega_micros.ino
Code for 4-channel TTL driver without PWM dimming.
Solder jumper wires to all eight of the outer pins on each rotary switch, and a normal wire to the central (ground) pin.
Solder wires to the toggle switches, one each to middle and one side pin.
For each LED, solder a jumper wire to the LED anode pin, and a 330 ohm resistor to the cathode pin; then a wire to the resistor.
Solder a jumper wire to each BNC signal pin (central pin), and a normal wire to each BNC ground (side pin).
If using dimming version: solder a jumper wire to the central pin on each potentiometer, and a normal wire to pin 1 (for +5V) and a normal wire to pin 3 (for ground)
Jumper wires make it easy to connect to the Arduino I/O pins, but there aren't sufficient ground pins, so you need to use normal wires, then solder those together.
Any exposed regions can be shielded with heat-shrink tubing if there is any concern of movement/contacting other bits.
2
Connect to Arduino
Plug the collated ground wires into an Arduino Ground pin, and the collated +5V wires into a +5V pin (if using a Due, use the +3.3V pin or you will damage the microcontroller) and plug the other jumper wires into the correct I/O pins:
Download the .ino file and upload the code to your Arduino Mega. If using the dimming version, I recommend using an Arduino Due (it has the same pin architecture as the Mega, but faster PWM).