#include <LiquidCrystal.h>
LiquidCrystal lcd(10, 9, 8, 7, 6, 5); // put your pin numbers here
byte index = 0;
int DMM_ARRAY[6]; // Where to store the Bytes read
byte c;
char SETUP = 0x65;
int n = 0;
float previousValue = 0;
float currentValue = 0;
uint32_t t = 0; // Time record was received '2', '3', '4', '5', '6', '7', '8', '9', ' ', 'L'};
void printRecord(Print* pr, char sep = ',') {
pr->print(t);
//pr->print(sep);
//pr->print(DMM_ARRAY[0]); // Print btye 0
//pr->print(sep);
//pr->print(DMM_ARRAY[1]); // Print btye 1
pr->print(sep);
pr->print(DMM_ARRAY[2]); // Print btye 2
pr->print(sep);
pr->print(DMM_ARRAY[3]); // Print btye 3
//pr->print(sep);
//pr->print(DMM_ARRAY[4]); // Print btye 4
//pr->print(sep);
//pr->print(DMM_ARRAY[5]); // Print btye 5
}
void setup() {
pinMode(11, OUTPUT); // LCD CONTRAST PIN
pinMode(2, OUTPUT); // Clear To Send PIN
pinMode(3, OUTPUT); // Clock PIN
digitalWrite(2, HIGH); // CTS CONSTANT HIGH
//tone(3,1); //CLOCK FREQ in HZ // minimum 31hz?
analogWrite(11, 50); //LCD CONTRAST AMOUNT
Serial.begin(1000000);
lcd.begin(16, 2);
lcd.print("GG1320AN21 TEST");
lcd.clear();
}
void loop() {
digitalWrite(3, HIGH);
delayMicroseconds(200);
digitalWrite(3, LOW);
Get_data(); //Read the Serial bytes coming in
//lcd.setCursor(0, 0);
//lcd.print( DMM_ARRAY[2]);// Print btye 3 (LSB)
//lcd.print(" ");
//lcd.setCursor(0, 1);
//lcd.print( DMM_ARRAY[3]);// Print btye 4 (MSB)
//lcd.print(" ");
//delay(1000);
//lcd.clear();
float angularVelocity;
currentValue = DMM_ARRAY[2];
angularVelocity =((currentValue - previousValue)*1.113065); // count * 1.113065 ARC SEC / SEC
lcd.setCursor(0, 0);
lcd.print(angularVelocity, 3); //3 decimal place values
//lcd.print(" ");
//lcd.setCursor(0, 1);
//lcd.println(" ArcSec/s ");
//lcd.print(" ");
previousValue = currentValue;
delay(1000);
lcd.clear();
}
void Get_data() {
if (Serial.available() >= 6) {
for (int i = 0; i < 6; i++) {
DMM_ARRAY[i] = Serial.read();
}
}
}
I have not adjusted the variables to be more readable yet, so sorry it will still be a bit tough to read.
I used another forum post to get something that I think it doing the trick for the moment.
I am currently reading what I believe is the 3rd Byte.
I need to figure out how to get a accurate 1 hz pulse to be sent to the gyro so I can accurately calculate the angular velocity while it is sitting still.
It currently is bouncing around the expected value so I think I am close. ![]()