Skip to content

Commit

Permalink
Fully implemented Epee detection system
Browse files Browse the repository at this point in the history
works for epee and can switch modes but the other modes wont currently work for foil and sabre as they have not been been implemented yet.
  • Loading branch information
Actual-Heathen authored Oct 18, 2021
1 parent 6ed290a commit 8f4ce28
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 8f4ce28

Please sign in to comment.