Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save OptogeneticsandNeuralEngineeringCore/a2a5eaba46bde958a66eecbba24ef410 to your computer and use it in GitHub Desktop.
Save OptogeneticsandNeuralEngineeringCore/a2a5eaba46bde958a66eecbba24ef410 to your computer and use it in GitHub Desktop.
/*
LED to drive optic stimulation of in vitro tissue, opsins excited by approperate wavelengths, controlled by TTLs.
Optogenetics and Neural Engineering Core ONE Core
University of Colorado
4 / 17 / 2018
See https://optogeneticsandneuralengineeringcore.github.io/ONECoreSite/ for more information, including a detailed write up and Arduino/BNC housing 3D Model
In this code, four TTL inputs are received by the Arduino, and an Adafruit Neuopixel LED chain (Adafruit 1430) is lit up (note that we use the FAST LED library, and therefore
currently cannot use the white LEDs.
If one TTL goes high, a blue (465 - 475nm or 467.5 - 470nm (it can ship with one of two flavors of LEDs: either WS2812B or SK6812)) light is emitted.
If another TTL goes high, a green (522.5 - 525nm or 515 - 530nm) light is emitted.
The final TTL controls a red (620 - 625nm or 620 - 630nm) light.
*/
#include <FastLED.h>
// How many leds in your strip?
#define NUMLED 40
int LEDSPACE = 1;
// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
#define DATA_PIN 6
#define NEO 6 // Pin to output to the Neopixel
#define BLU 2 // Set this to high to output turn on blue light
#define GRE 4 // Set this to high to output turn on green light
#define RED 7 // Set this to high to output turn on red light
#define WHI 8 // Set this to high to output turn on white light
// Define the array of leds
CRGB leds[NUMLED];
void setup()
{
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUMLED);
}
void loop() {
int DRBLU = digitalRead(BLU);
int DRGRE = digitalRead(GRE);
int DRRED = digitalRead(RED);
int DRWHI = digitalRead(WHI);
if (DRBLU == HIGH)
{
for (int i = 0; i < NUMLED; i = i + LEDSPACE)
{
leds[i] = CRGB::Blue;
}
FastLED.show();
}
if (DRGRE == HIGH)
{
for (int i = 0; i < NUMLED; i = i + LEDSPACE)
{
leds[i] = CRGB::Green;
}
FastLED.show();
}
if (DRRED == HIGH)
{
for (int i = 0; i < NUMLED; i = i + LEDSPACE)
{
leds[i] = CRGB::Red;
}
FastLED.show();
}
if (DRWHI == HIGH)
{
for (int i = 0; i < NUMLED; i = i + LEDSPACE)
{
leds[i] = CRGB::White;
}
FastLED.show();
}
if (DRBLU == LOW && DRGRE == LOW && DRRED == LOW && DRWHI == LOW)
{
for (int i = 0; i < NUMLED; i = i + LEDSPACE)
{
leds[i] = CRGB::Black;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment