Buzz Off: An Unusual Switch

In this production assignment, we had to create an unusual switch that does not require the use of hands and involves digital input and output for interaction. For this, I created a buzz game, where touching the course using the loop would close the switch. This, in turn, would stop the green LED and the red LED will start blinking.

This unusual game requires you to move the loop across the course using wrists. Sounds interesting but it is pretty difficult. I spent so much time simplifying and making the course yet interesting. I am yet to find someone that could complete this with the loop between wrists and without buzzing the circuit.

Here’s the complete circuit :

 

 

 

 

 

 

 

 

 

Let’s play:

P.S Sorry for the bad video editing/ timing

The code is pretty simple and short. I have added a variable that keeps track of how many frames the switch has been closed –  a measure of how bad you are at this game.

//global variables
int ledPingreen = 2;
int ledPinred = 4;
int input_ledPin = 7;
int touches = 0;
unsigned long timer = 0;
int timerAmount = 50;
bool flip = false;

void setup() {
  // put your setup code here, to run once:
  pinMode(input_ledPin, INPUT);
  pinMode(ledPinred, OUTPUT);
  pinMode(ledPingreen, OUTPUT);
  
  //initiate timer
  timer = millis();

  //keep track of touches and monitor it
  touches = 0;
  Serial.begin(9600);
  
}

void loop() {
  //monitoring touches
  Serial.print("Number of touches until now : ");
  Serial.println(touches);

  //if the switch is closed
   if(digitalRead(input_ledPin)==HIGH){
    //increment number of touches
    touches += 1;
    //blink the red LED
    if(millis()>= timer){
      flip = !flip;
      digitalWrite(ledPinred, flip);
      timer = millis()+timerAmount;
    }
    //turn of green LED
    digitalWrite(ledPingreen, LOW);
   }

   //if open
   else{
    //turn green LED on and red off
    digitalWrite(ledPinred, LOW);
    digitalWrite(ledPingreen, HIGH);
   }
}

Leave a Reply