Hello all, I've been attempting to craft a timing system for my school's track team by utilizing two tf minis that are connected by a wireless transceiver from hiLetgo on amazon. My issue arises from getting both the transceivers to work and to get the timers to function and print on the lcd. I don't know how the receivers talk to one another or if I'd need a set of code for such. I also cannot see that the timer has started as it won't print on my lcd. My code is below. Any help is greatly appreciated!
#include <LiquidCrystal.h>
#include "Timer.h"
#include <SoftwareSerial.h>
#include "TFMini.h"
TFMini tfmini;
Timer timer;
SoftwareSerial SerialTFMini(2, 3); //The only value that matters here is the first one, 2, Rx
const int rs = 12, en = 11, d4 = 7, d5 = 6, d6 = 5, d7 = 4;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void getTFminiData(int* distance, int* strength) {
static char i = 0;
char j = 0;
int checksum = 0;
static int rx[9];
if (SerialTFMini.available()) {
rx[i] = SerialTFMini.read();
if (rx[0] != 0x59) {
i = 0;
} else if (i == 1 && rx[1] != 0x59) {
i = 0;
} else if (i == 8) {
for (j = 0; j < 8; j++) {
checksum += rx[j];
}
if (rx[8] == (checksum % 256)) {
*distance = rx[2] + rx[3] * 256;
*strength = rx[4] + rx[5] * 256;
}
i = 0;
} else {
i++;
}
}
}
void setup() {
Serial.begin(115200); //Initialize hardware serial port (serial debug port)
while (!Serial)
; // wait for serial port to connect. Needed for native USB port only
Serial.println("Initializing...");
SerialTFMini.begin(TFMINI_BAUDRATE); //Initialize the data rate for the SoftwareSerial port
tfmini.begin(&SerialTFMini); //Initialize the TF Mini sensor
}
void loop() {
int distance = 0;
int strength = 0;
getTFminiData(&distance, &strength);
while (!distance) {
getTFminiData(&distance, &strength);
if (distance < 150)
if (timer.state() == RUNNING) (timer.stop);
else timer.start();
lcd.print(currentMillis());
}
delay(00);
}