I’m building a laser timing gate for my lab and ran into a stopping point. Essentially I am trying to build a prototype laser timing gate that will display a direction of either left or right facing triangle when the laser is broken. This will be used for sports performance drills and data collection. As of right now I have it working to display a single triangle pointing to the right and it works! When the beam is broken it will display a triangle on an adafruit LED Matrix.
What I’d like to do is use the matrix triangle as an object (one that points right and one that points left) and have it called in either a random order or a predetermined order so that it doesn’t always point in one direction when the laser is broken. My idea currently is to create an array of states the LED could be in (either a 1 as right or a 2 as left), and have it choose a direction each time.
OR to create 8 states like (1,2,2,1,2,1,2,1), and have the loop increment each time across the array until it reaches the count number of 8 so that it moves from left to right facing arrows and we can record the direction the subject had to move and can pair it with the motion capture data we are getting.
So my question is: Can I turn the adafruit matrix function into a variable that can be called and put into an array? If so, how could I do that? Thanks.
This code is for use with a Light Dependent Resistor as a second device of a timing gate
for UC Health Motion Capture Lab under Dr. Kate Worster.
This portion of the gate will receive a signal from Gate 1 via an LDR, and signal
what direction an LED matrix will signal a runner to go.
This device should be able to output serial monitor data to a MATLAB plot,
as well as send a 5V pulse to a vicon monitor to be labeled as a general GAIT event
in the Nexus software.
created 10 Feb 2020
by Gary J Schneider
/////////////////////////Libraries for LED Matrix/////////////////////////
int ledPin1 = 5; // green led pin(2)
int ledPin2 = 6; // red led pin(4)
int photo = A0; // photoresistor pin(10)
int x = 1; // initial value for x
//////////////////////////LED Display Pins////////////////////////////////
#define HT_DATA 2
#define HT_WR 3
#define HT_CS 4
#define BACKCOLOR 0xF800
Adafruit_HT1632LEDMatrix matrix = Adafruit_HT1632LEDMatrix(HT_DATA, HT_WR, HT_CS);
Begin serial monitoring of the photoresistor, ensure the LED’s are set
to output.Will provide the users a notifcation of power on through a single
flash of the LED panel that will occur when turned on.
//1. Assign x the value of the LDR sensor
//2. Print the value of the LDR sensor in serial monitor
//3. Print LDR value in the serial monitor
//4. Inital value of c = 0
x = analogRead(photo);
if (x < 600) //Laser is broken and light value under 600, do this…
digitalWrite(ledPin1, LOW); // turn green led off
digitalWrite(ledPin2, HIGH); // turn red led on
** matrix.fillTriangle(4, 0, 4, 15, 22, 8, BACKCOLOR); //Creates right pointing triangle**
delay(1500); //Delay the clearing of the screen so runner has time to read
else (x > 600)// if laser link is in tact…
digitalWrite(ledPin1, HIGH); // turn green led on
digitalWrite(ledPin2, LOW); // turn red led off