you have digitalWrite(CTSPin, HIGH); // CTS Open that is done always after 1s but you make it LOW only if you got the data, so the idea was to make it LOW in both cases.
or may be you want to move the whole section
digitalWrite(CTSPin, HIGH); // CTS Open
digitalWrite(RSPin, HIGH); // RS
delayMicroseconds(50);
digitalWrite(RSPin, LOW); //RS
into the if (Get_data()) {
so like this
#include <LiquidCrystal.h>
LiquidCrystal lcd(10, 9, 8, 7, 6, 5); // put your pin numbers here
const byte lcdContrastPin = 11; // LCD CONTRAST PIN
const byte CTSPin = 2; // Clear To Send PIN
const byte RSPin = 3; // Request Sample PIN
byte DMM_ARRAY[6]; // Where to store the Bytes read
bool Get_data() {
bool success = (Serial.available() >= 6);
if (success) Serial.readBytes(DMM_ARRAY, 6);
return success;
}
void setup() {
pinMode(CTSPin, OUTPUT);
pinMode(RSPin, OUTPUT);
pinMode(lcdContrastPin, OUTPUT);
analogWrite(lcdContrastPin, 50); //LCD CONTRAST AMOUNT
Serial.begin(1000000);
lcd.begin(16, 2);
lcd.print(F("GG1320AN21 TEST"));
}
void loop() {
static float previousValue = 0;
unsigned long previousMicros = 0;
float deltaTheta;
unsigned long currentMicros = micros(); // you could do this with millis() too, depends on the precision you want
if (currentMicros - previousMicros >= 1000000ul) { // 1s in µs
if (Get_data()) { // Read the Serial bytes coming in
unsigned long deltaT = currentMicros - previousMicros; // that will be give or take 1s
float currentValue = DMM_ARRAY[2];
digitalWrite(CTSPin, HIGH); // CTS Open
digitalWrite(RSPin, HIGH); // RS
delayMicroseconds(50);
digitalWrite(RSPin, LOW); // RS
delayMicroseconds( 200 );
digitalWrite(CTSPin, LOW); // CTS Close
deltaTheta = ((previousValue - currentValue) * 1.113065); // count * 1.113065 ARC SEC / SEC
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(deltaTheta / (deltaT / 1000000.0)); //3 decimal place values
lcd.setCursor(0, 1);
lcd.print(DMM_ARRAY[2]);// Print btye 3 (LSB)
previousValue = currentValue;
previousMicros = currentMicros;
}
}
}