ericmelvin10

Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: Programation Defusable Clock V2 #2335
    ericmelvin10
    Member

    In the function countdown:

    I set the pins to wires (one for automatic detonation[Wire_1] and 3 for defusing sequence[Wire_2–>Wire_4–>Wire_3])

      defusePin = WIRE_2;
    defusePin2 = WIRE_4;
    defusePin3 = WIRE_3;
    detPin = WIRE_1;
    DetState = 0;

    Then in the main loop of the function:

    while ((countdownSeconds > 0) && (!defused))  {
    for(int i=0;i<10000;i++) {

    if (digitalRead(detPin) == HIGH) {
    countdownSeconds = 0;
    break;
    }
    // old stuff commented ;-)
    /*if (digitalRead(defusePin) == HIGH) {
    defused = true;
    break;
    }*/

    //enters the sequence:

    if ((digitalRead(defusePin) == HIGH) && (DetState == 0))
    {
    DetState++;
    beep(4200, 30); //just a noise for comfirmation :)

    }
    if ((digitalRead(defusePin2) == HIGH) && (DetState < 1))
    {
    countdownSeconds = 0;
    }
    else if ((digitalRead(defusePin2) == HIGH) && (DetState == 1))
    {
    DetState++;
    beep(4200, 30);
    }
    if ((digitalRead(defusePin3) == HIGH) && (DetState < 2))
    {
    countdownSeconds = 0;
    }
    else if ((digitalRead(defusePin3) == HIGH) && (DetState == 2))
    {
    defused = true;
    }
    }

    As you can see, it’s pretty simple , but works like a charm 🙂

    in reply to: Programation Defusable Clock V2 #2321
    ericmelvin10
    Member

    I’ve re-programmed to defuse it cutting the wires in sequence.

Viewing 2 posts - 1 through 2 (of 2 total)