Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
paulsb
Published © GPL3+

Fastest Finger First

Identifies who has responded first to a question by triggering a visual and audio indication. Up to 3 players but could easily be extended.

BeginnerShowcase (no instructions)2,415
Fastest Finger First

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
You could also use an Arduino Nano.
×1
5 mm LED: Red
5 mm LED: Red
×1
5 mm LED: Green
5 mm LED: Green
×1
5 mm LED: Yellow
5 mm LED: Yellow
×1
Tactile Switch, Top Actuated
Tactile Switch, Top Actuated
×4
Buzzer
Buzzer
Passive buzzer (maybe 82Y9713 rather than the above code)
×1
Resistor 1k ohm
Resistor 1k ohm
×3
Breadboard (generic)
Breadboard (generic)
×1

Story

Read more

Schematics

Fastest Finger First

Fastest Finger First - Breadboard

Fastest Finger First Schematic

Code

Fastest Finger First

Arduino
Arduino code
// Paul Brace
// 8 Jan 2021

// fastest finger first
// 3 buttons - first one pressed lights their light and hears their tone
// Reset button flashes all lights twice (proves they are working)
// then waits.

int redButton = 1;
int greenButton = 2;
int amberButton = 3;
int redLED = 4;
int greenLED = 5;
int amberLED = 6;
int buzzer = 7;
int resetButton = 8;
bool waiting = false;
int redNote = 262; 
int greenNote = 523; 
int amberNote = 1047; 
int duration = 250;

void setup() {
  pinMode(redButton, INPUT_PULLUP);
  pinMode(greenButton, INPUT_PULLUP);
  pinMode(amberButton, INPUT_PULLUP);
  pinMode(resetButton, INPUT_PULLUP);
  pinMode(redLED, OUTPUT);
  pinMode(greenLED, OUTPUT);
  pinMode(amberLED, OUTPUT);
  pinMode(buzzer, OUTPUT);
  // Flash 4 times (each call flashes twice) to show ready
  for (int i = 0; i < 2; i++) {
    FlashLEDs();
  }
}

void FlashLEDs() {
  for (int i = 0; i < 2; i++){
    digitalWrite(redLED, HIGH);
    digitalWrite(greenLED, HIGH);
    digitalWrite(amberLED, HIGH);
    delay(500);
    digitalWrite(redLED, LOW);
    digitalWrite(greenLED, LOW);
    digitalWrite(amberLED, LOW);
    delay(500);
  }
  waiting = true;
}

bool checkButtons(){
  // Check to see if a button has been pressed
  // If there is a dead heat (very unlikely) both lights will show
  bool pressed = false;
  if (digitalRead(amberButton) == LOW){
    digitalWrite(amberLED, HIGH);
    tone(buzzer, amberNote, duration);
    pressed = true;
  }
  if (digitalRead(redButton) == LOW){
    digitalWrite(redLED, HIGH);
    tone(buzzer, redNote, duration);
    pressed = true;
  }
  if (digitalRead(greenButton) == LOW){
    digitalWrite(greenLED, HIGH);
    tone(buzzer, greenNote, duration);
    pressed = true;
  }
  return(pressed);
}

void loop() {
  if (digitalRead(resetButton) == LOW)
  {
    FlashLEDs();
  }
  if (waiting){
    waiting = !checkButtons();
  }
}

Credits

paulsb
4 projects • 28 followers
Contact

Comments

Please log in or sign up to comment.