Skip to content

Commit

Permalink
Merge pull request #34 from luis-1063/main
Browse files Browse the repository at this point in the history
Fully implemented Epee detection system, missing foil, sabre
  • Loading branch information
jaguar017 authored Oct 23, 2021
2 parents 6ed290a + 8f4ce28 commit d52a92e
Showing 1 changed file with 56 additions and 16 deletions.
72 changes: 56 additions & 16 deletions Fencing Detection/Fencing.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,70 @@ int mode = 0; // 0 epee, 1 foil, 2 sabre
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11,OUTPUT);
pinMode(10, INPUT);
}

void loop()
{

while (mode == 0)
{
int val1 = analogRead(analogPin1);
if (mode == 0) //Epee
{
int val1 = analogRead(analogPin1); // hit detection Arithmatic
int val2 = analogRead(analogPin2);
float volt1 = val*(5.0/1023.0);
float volt2 = val*(5.0/1023.0);
float volt1 = val1*(5.0/1023.0);
float volt2 = val2*(5.0/1023.0);

if (volt1 == 5.0 || volt2 == 5.0)
if (volt1 == 5.0 || volt2 >= 4.5)
{
if (volt1 == 5.0)
unsigned long timelock = (micros() + 40000); // set a time 40 milisecods after the first hit;

digitalWrite(11, HIGH);

while (micros() < timelock ) //lockout after 40 millis.
{
digitalWrite(LED_BUILTIN, HIGH);
if (volt1 == 5.0)
{
digitalWrite(13, HIGH);
}
if (volt2 == 5.0)
{
digitalWrite(12, HIGH);
}

val1 = analogRead(analogPin1);
val2 = analogRead(analogPin2);
volt1 = val1*(5.0/1023.0);
volt2 = val2*(5.0/1023.0);

Serial.print(timelock - micros());
Serial.print("\n");
}
digitalWrite(11, LOW);
delay (2000);
digitalWrite(13, LOW);
digitalWrite(12, LOW);

}
}
while (mode == 1)
{
}
while (mode == 2)
{
}
}
if (mode == 1) //Foil
{

}
if (mode == 2) //Sabre
{

}

if (digitalRead(10) == HIGH)
{
mode++;
delay(1000);
}
if (mode > 2)
{
mode = 0;
}

Serial.print(mode);
}

0 comments on commit d52a92e

Please sign in to comment.