top of page
Final droduct design:

Poster:

Brochure:

Tech Drawing:

Arduino:

IRCT CODE

const int buttonPins[] = {2, 5, 8, 11, 14, 17, 51, 23, 26, 29, 32, 35, 38, 41, 44, 47};

const int ledAPins[] = {3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48};

const int ledBPins[] = {4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49};

 

const int buttonStartPin = 50;

const int numBut = 16; //16;

 

bool reset = true;

 

bool hit[numBut];

bool owner[numBut]; // owner : false = player green, true = player orange

 

void setup() {

 

  Serial.begin(9600);

  Serial.println("Hello!");

 

  for (int i = 0; i < numBut; i++) {

    pinMode (buttonPins[i], INPUT);

    pinMode (ledAPins[i], OUTPUT);

    pinMode (ledBPins[i], OUTPUT);

    digitalWrite(ledAPins[i], HIGH);

    digitalWrite(ledBPins[i], HIGH);

    delay(100);

    digitalWrite(ledAPins[i], LOW);

    digitalWrite(ledBPins[i], LOW);

  }

 

  for (int i = 0; i < numBut; i++) {

    digitalWrite(ledAPins[i], HIGH);

    digitalWrite(ledBPins[i], HIGH);

  }

 

  // while(1); // stop everything past here

 

} // setup

 

void loop() {

 

  // ---------------- RESET EVERYTHING ----------

  reset = digitalRead(buttonStartPin);

 

  if (reset) {

    for (int i = 0; i < numBut; i++) {

      digitalWrite(ledAPins[i], LOW);

      digitalWrite(ledBPins[i], LOW);

      hit[i] = false;

      owner[i] = false;

    }

    reset = false;

  } //if

 

  // Look for hits and set the hitter

  for (int i = 0; i < numBut; i++) {

    bool tempHit = digitalRead(buttonPins[i]);

   

    if (tempHit) {

      hit[i] = true;

      if (i < 8) owner[i] = false; // green

      if (i >= 8) owner[i-8] = true; // orange

    } //for

    Serial.print(i); Serial.print(":"); Serial.print(owner[i]); Serial.print(" ");

  } // for

  Serial.println();

 

  // setup the lights

 

  for (int i = 0; i < numBut / 2; i++) {

    if (hit[i]) {  

      if (owner[i]) { //orange

        digitalWrite(ledAPins[i], LOW);

        digitalWrite(ledAPins[i + 8], LOW);

        digitalWrite(ledBPins[i], HIGH);

        digitalWrite(ledBPins[i + 8], HIGH);

      }

      if (!owner[i]) { // green

        digitalWrite(ledAPins[i], HIGH);

        digitalWrite(ledAPins[i + 8], HIGH);

        digitalWrite(ledBPins[i], LOW);

        digitalWrite(ledBPins[i + 8], LOW);

      }

    } //hit

  } // for

} // loop

SART CODE

#include <Servo.h>

 

const int buttonPin = 2;

int buttonState = 0;

 

Servo servo1;

Servo servo2;

 

bool runSeq = false;

 

void setup() {

  Serial.begin(9600);

  pinMode(2, INPUT);

  servo1.attach(10);

  servo2.attach(9);

}

 

void loop() {

  buttonState = digitalRead(buttonPin);

  if(buttonState) runSeq = !runSeq;

  delay(100);

 

  Serial.println(buttonState);

  if (runSeq) {

    // first position

    servo1.write(random(0,180)); // pivot randomly between 0 and 180 degrees

    delay(1000);

    servo2.write(180); // open

    delay(1000); // gate open timer

    servo2.write(0); // close

 

  } else {

 

    servo1.write(90); // centre point

    delay(0);

    servo2.write(0); //closed

    delay(0);

 

  }

  }

Vedio:

PDF Report:

bottom of page