Skip to content

Commit

Permalink
Merge pull request #1 from Shaking-Hands-Overseas/lucas-vrtech-patch-1
Browse files Browse the repository at this point in the history
Add finger calibration scaling, and faster serial
  • Loading branch information
Newtoniano20 committed Apr 8, 2022
2 parents 6980728 + 5064e3d commit 9e9d95d
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions Sender_ESP32/Sender_ESP32.ino
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
int A[] = {32, 32, 32, 32, 32};

int A[] = {36, 39, 32, 34, 35};
int maxes[] = {0, 0, 0, 0, 0};
int mins[] = {180,180,180,180,180};

void setup() {
Serial.begin(9600); // // Serial Communication is starting with 9600 of baudrate speed
Expand All @@ -13,20 +14,25 @@ String normal(int s){
};

void loop() {
int s1 = int(analogRead(A[0])); // Reading data from Analog port A0
int s2 = int(analogRead(A[1])); // Reading data from Analog port A1
int s3 = int(analogRead(A[2])); // Reading data from Analog port A2
int s4 = int(analogRead(A[3])); // Reading data from Analog port A3
int s5 = int(analogRead(A[4])); // Reading data from Analog port A4
String sensors_reading[] = {reverse(s1), normal(s2), normal(s3), reverse(s4), normal(s5)}; // Creating a dictionary where we have stored each value,
int s[] = {analogRead(A[0]), analogRead(A[1]), analogRead(A[2]), analogRead(A[3]), analogRead(A[4])}; //Reading data from Analog ports A0-A4

for (int i = 0; i < 5; i++){
if (s[i] > maxes[i])
maxes[i] = s[i];
if (s[i] < mins[i])
mins[i] = s[i];

s[i] = map(s[i], mins[i], maxes[i], 0, 4095);
}

String sensors_reading[] = {reverse(s[0]), normal(s[1]), normal(s[2]), reverse(s[3]), normal(s[4])}; // Creating a dictionary where we have stored each value,
// with reversed values included
//Data Transmission to the python code via serial port
String Read = String(Serial.read()); // reading the serial port
char Read[100];
Serial.readBytesUntil('A', Read, 100);

if (Read = "A"){ // If we recieve an "A" through the serial port, we send the data
String Info = " " + sensors_reading[0] + " " + sensors_reading[1] + " " + sensors_reading[2] + " " + sensors_reading[3] + " " + sensors_reading[4] + " ";
Serial.println(Info); //We Send the data
}

delay(150); // 1s of delay, to avoid overflow
}

0 comments on commit 9e9d95d

Please sign in to comment.