Skip to content

Commit

Permalink
full epee system with mode switch
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Lazcano committed Oct 6, 2021
1 parent a207a97 commit caef423
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 17 deletions.
Binary file modified .vs/slnx.sqlite
Binary file not shown.
67 changes: 50 additions & 17 deletions Fencing.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +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)
{
for (int i = 0; i < 40000; i++)
unsigned long timelock = (micros() + 40000); // set a time 40 milisecods after the first hit;

digitalWrite(11, HIGH);

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

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);

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

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

}

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

Serial.print(mode);
}

0 comments on commit caef423

Please sign in to comment.