12 button wireless buzzer game - ambitious?

Too much chaff in the wheat. I wish you would draw a demonstrative, non-artistic, picture of the layout and the devices to be used.

Here's a boring idea (because sometimes it takes a bad idea to bring out better ideas): Make a web page for "voting" that students and faculty can pull up on a wireless device. Loads of templates on the internet on how to make a button cast a vote.

Bear in mind

I was going to suggest "raise their hands," but thought I might face disciplinary action, so, I'm back to old school... "l i t e r a l l y"

lol ...if I was in the west a poll might have been fun ... but Im in the middle of Vietnam .. I don't understand their lingo and and they definitly don't understand mine ... translate only gets you so far. I'll be posting pics soon enough , I'll try posting as I progress. Just stumbled on something I though was useful ... may or may not use it! https://www.youtube.com/watch?v=r_yobwaBWr0&t=693s Be able to choose the size of the score board....another option is to use a CD4026 IC ...much simpler/no programming/less likely to go belly up! ?????

You can change that, and should. Your effectiveness will be increased when cultural difference can be explained.

Highly doubtful, and they probably speak some level of French, too.

well thats my purpose for being here ... esl English teacher. Many speak English but not very well ...my wife (Viet) studied English at uni .. although we been together a good 7 years now ... I still have to ask her to repeat herself constantly. As for me speaking Viet ... that will be the day pigs fly! I do not pick up on the tones and its all tonal ...high pitched and tonal ! At times when she goes off at me I swear she sounds like a dentists drill ....

You are a guest of theirs'. Do yourself a favor and learn enough language (spoken and written) to not need to ask twice. It will greatly enhance your experience, and those around you. I spent a couple decades overseas. I got a minor in one of the languages I learned... and I was just a technician. The language sounds like "noise" to you now, but as you learn, it contains all the meaning and emphasis as the language you speak, and none of it is noise. Enjoy your time. It will fly past.

So how are they not going to break your stuff ?

In the same series they have a « tough » version

Screw it to the desk :)


I do believe kids bad behavior is not a given fact esp with a small group and no I never damaged a table with a sharp object when at school …

yea that does look super cool thanks for your effort ... I did have a look at it and watched a review ... but last night before I closed shop I was messing around on google ai overview and stumbled and tripped on something vely vely promising. --- Boergi/ESP-Quiz-Buzzer ...you guys can have a look see!

same thing as what you displayed above ... do I need a touch screen display ??

This has eveything I wanted ..had a million thoughts running through my head, so much so, had a tough time falling asleep. Only one thing not added is sound but I'm sure I can work around that and add to the system!

IT HAS EVERYTHING !!! If this guy was incharge of DNA testing on Monica clothing ..Bad billy boy would have been strung up instead of being impeached! he has it all documented ... parts list, 3d printed boxes, wiring guides and user manuals ... The only thing not included is a price tag for his work ... so a big shout out and thank you to MR Boergi (where ever you are in the world)

tonights mission is to download the stl files ... and make some changes on tinkercad to the buzzers themselves - need to make them a little more minion proof - need them a little larger and double the wall thickness ... instead of printing them with PLA which is far too brittle ..Im going with transparent PETG ...The entire box will light up like a christmas tree ! .. its tough stuff, better layer adhesion! (and the cool thing is I can print spares - parts and complete buzzer sets ...keep them at arms length ) ... I'll keep you guys updated!

I suggest that before you go very much further that you work out how and where you are going to display the data. To my mind the button boxes are the least of your problems

Thirty of them.

the display/ scoring system I decided will be custom made and seperated from the game electronics... similiar to this ... https://www.youtube.com/watch?v=r_yobwaBWr0&t=693s ... with coding found here ... https://www.youtube.com/watch?v=7Y_uvV22_X0 ....any probs with that ... I got your number ...lol! I have both a cnc and a 3d printer .. so not to concerned about making it... looks pretty straight forward. As for the powerpoint presentation I already made head way with that over the past few weeks building a curriculum ... began with that so I could get an idea of what I would needed .... Lastly as for keeping track of the points system for the little shop I intend to run .. Going to hand that over to my TA (teaching assistant) .. thier work load will be reduced in class giving them time to update scores manually etc maybe on an excel work sheet until I find something better!

You can make sturdy devices if you build them into desks.

For non-touch no moving parts buttons you can use under-surface piezo disks or capacitive sensing and then the surface to be tapped or touched can be replaceable.

I went to school with low-tech hand raising and teacher as the smart part with 23 to 30 kids per class.

I remember 1st grade and subtraction being a pita. In 4th grade I got ahead on multiplication and the teacher showed me about numbers to the left of zero and how addition goes to the right and subtraction goes left, it's about direction and that's when subtraction stopped being a pain for me. If the students had linear slide rules with zero at center, 8 cm could go from -50 to +50 on top and 50 to 150 on the bottom. Just using one would show the user how numbers add and subtract and in general; work. It's important to include zero and negative numbers, they are not beyond all of the class but getting them to notice and get into... that's your hard part, me; I'd let them think they're not supposed to know that yet and bread-crumb the smart ones.

Just got the show on the road --- 1.6 million dong (a little over $60) ..my soldering not the greatest so got me some expansion boards and filament too!

remember that satisfaction you got from slamming an old fashion phone down in someone's face .... not quite the same as pressing the end call button on your mobile ! I recon piezo's may be an ''end call button'' ... technology took that away from us .. Think it will be more fun for the kids pounding away on the buzzers!

yea today schools are very different enviroments - its a business and one needs to stay ahead of the game ...with parents having more say now than ever before and with every school competing for heads ...it has become a petri dish for tech!

the disk can detect a knock on the other side of the door be it fist or hammer.

You don't have them bang the piezo, you have them bang something cheap and replaceable.. the piezo detects the bang or even a finger tap (they are extremely sensitive) THROUGH solid material.

A capacitive sensor is a bit of foild or conductive paint set BELOW an insulating protective surface that can be designed to be replaced when carved or defaced.

Buttons that mechanically move to work will wear out, quicker for being slammed. Make a button that can take beatings but sense the button in a way that can't be touched and it will last.

lol...I did do a little reading on them before replying on the last message ....you know whats going to happen once they figure out how sensitive the piezo's are .. slap the person's desk next door, or kick it for a laugh ... that will be followed by monkey see , monkey do ...before long you gonna have buzzers going off all over the place ... which will just lead to more problem solving.

In the parts list he has specified a spring to use ...think is was about .93 kg , something like that ...I'd actually like to get something a little stiffer.

Got interested in how to solve the problem of determining which Student remote pressed the button first and decided to test my solution of having a local time beacon... sort of like WWV where all the remotes could synchronize their local time bases to a standard.
The setup is a Seeed XIAO ESP32-C6 programmed to transmit over ESPNOW channel 6 a #of_microseconds and sequence# every second. The Student remotes continually receive this signal and use it to synchronize a local timestamp. When a Student presses a button, the event is time-stamped and a Teacher unit can poll all the students to determine which one actually pressed their button first.


You can see that network Beacon Time is backed into by adding Elapsed since beacon + Network button time.

My reason for doing this was threefold. I hadn't used AI to write a sketch before and wanted to see how practical it is to have a design chat with AI to develop a workable solution. Second, I have just started using the Seeed XIAO modules and wanted to have an actual project rather than just running the examples. Third I was curious how easy it was going to be to determine when an event happened with only a wireless connection as opposed to using hardwired switches.

Time Beacon
/*
  ESP-NOW time beacon for a Seeed Studio XIAO ESP32-C6.

  Once per second this sketch broadcasts:
    - a beacon sequence number
    - the master's esp_timer_get_time() value in microseconds

  Use with ESPNow_Time_Client.ino. Both boards must use the same
  ESPNOW_CHANNEL value.

  Target: Arduino-ESP32 core 3.x, board "XIAO_ESP32C6".
*/

#include <Arduino.h>
#include <WiFi.h>
#include <esp_now.h>
#include <esp_timer.h>
#include <esp_wifi.h>
#include <inttypes.h>

namespace {

constexpr uint8_t ESPNOW_CHANNEL = 6;
constexpr int64_t BEACON_PERIOD_US = 1000000LL;
constexpr uint32_t PACKET_MAGIC = 0x54494D45UL;  // ASCII "TIME"
constexpr uint8_t PROTOCOL_VERSION = 1;
constexpr uint8_t PACKET_TYPE_BEACON = 1;

const uint8_t BROADCAST_ADDRESS[ESP_NOW_ETH_ALEN] = {
    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

struct __attribute__((packed)) TimeBeacon {
  uint32_t magic;
  uint8_t version;
  uint8_t packetType;
  uint16_t packetSize;
  uint32_t sequence;
  int64_t masterTimeUs;
};

static_assert(sizeof(TimeBeacon) == 20, "Unexpected TimeBeacon size");

uint32_t beaconSequence = 0;
int64_t nextBeaconUs = 0;

void stopWithError(const char *message, esp_err_t error) {
  Serial.printf("%s: %s (%d)\n", message, esp_err_to_name(error), error);
  while (true) {
    delay(1000);
  }
}

void initializeEspNow() {
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  esp_err_t error =
      esp_wifi_set_channel(ESPNOW_CHANNEL, WIFI_SECOND_CHAN_NONE);
  if (error != ESP_OK) {
    stopWithError("Could not set the Wi-Fi channel", error);
  }

  error = esp_now_init();
  if (error != ESP_OK) {
    stopWithError("Could not initialize ESP-NOW", error);
  }

  esp_now_peer_info_t broadcastPeer = {};
  memcpy(broadcastPeer.peer_addr, BROADCAST_ADDRESS, ESP_NOW_ETH_ALEN);
  broadcastPeer.channel = ESPNOW_CHANNEL;
  broadcastPeer.ifidx = WIFI_IF_STA;
  broadcastPeer.encrypt = false;

  error = esp_now_add_peer(&broadcastPeer);
  if (error != ESP_OK && error != ESP_ERR_ESPNOW_EXIST) {
    stopWithError("Could not add the broadcast peer", error);
  }
}

void sendTimeBeacon() {
  TimeBeacon beacon = {};
  beacon.magic = PACKET_MAGIC;
  beacon.version = PROTOCOL_VERSION;
  beacon.packetType = PACKET_TYPE_BEACON;
  beacon.packetSize = sizeof(beacon);
  beacon.sequence = ++beaconSequence;

  // Take this timestamp as close as possible to esp_now_send(). The delay
  // between this statement and actual RF transmission is approximately
  // common to every client that receives this particular beacon.
  beacon.masterTimeUs = esp_timer_get_time();

  const esp_err_t error = esp_now_send(
      BROADCAST_ADDRESS, reinterpret_cast<const uint8_t *>(&beacon),
      sizeof(beacon));

  if (error == ESP_OK) {
    Serial.printf("Beacon %" PRIu32 ", master time %" PRId64 " us\n",
                  beacon.sequence, beacon.masterTimeUs);
  } else {
    Serial.printf("Beacon send failed: %s (%d)\n", esp_err_to_name(error),
                  error);
  }
}

}  // namespace

void setup() {
  Serial.begin(115200);
  const uint32_t serialWaitStarted = millis();
  while (!Serial && millis() - serialWaitStarted < 3000) {
    delay(10); 
  } // seems like a hack but AI swears blind all the cool kids are doing it

  Serial.println();
  Serial.println("ESP-NOW time beacon");

  initializeEspNow();

  Serial.printf("Station MAC: %s\n", WiFi.macAddress().c_str());
  Serial.printf("ESP-NOW channel: %u\n", ESPNOW_CHANNEL);

  // Send the first beacon promptly. Subsequent deadlines remain exactly one
  // second apart rather than accumulating loop timing error.
  nextBeaconUs = esp_timer_get_time() + 100000LL;
}

void loop() {
  const int64_t nowUs = esp_timer_get_time();

  if (nowUs >= nextBeaconUs) {
    sendTimeBeacon();

    do {
      nextBeaconUs += BEACON_PERIOD_US;
    } while (nextBeaconUs <= nowUs);
  }

  delay(1);
}

Time Client
/*
  ESP-NOW time-beacon client for a Seeed Studio XIAO ESP32-C6.

  Connect a normally-open pushbutton between XIAO pin D1 (GPIO1) and GND.
  The internal pull-up is enabled. The first falling edge is timestamped;
  switch debounce is performed afterward without changing that timestamp.

  The Serial Monitor prints the button time expressed in the master's time
  domain. This first experiment does not transmit the result back to the
  master; polling can be added after synchronization has been characterized.

  Target: Arduino-ESP32 core 3.x, board "XIAO_ESP32C6".
*/

#include <Arduino.h>
#include <WiFi.h>
#include <esp_now.h>
#include <esp_timer.h>
#include <esp_wifi.h>
#include <inttypes.h>

namespace {

constexpr uint8_t ESPNOW_CHANNEL = 6;
constexpr uint8_t BUTTON_PIN = D1;  // XIAO ESP32-C6 D1 is GPIO1.
constexpr uint32_t RELEASE_DEBOUNCE_MS = 30;
constexpr uint32_t PACKET_MAGIC = 0x54494D45UL;  // ASCII "TIME"
constexpr uint8_t PROTOCOL_VERSION = 1;
constexpr uint8_t PACKET_TYPE_BEACON = 1;

struct __attribute__((packed)) TimeBeacon {
  uint32_t magic;
  uint8_t version;
  uint8_t packetType;
  uint16_t packetSize;
  uint32_t sequence;
  int64_t masterTimeUs;
};

static_assert(sizeof(TimeBeacon) == 20, "Unexpected TimeBeacon size");

portMUX_TYPE timeMux = portMUX_INITIALIZER_UNLOCKED;

// Latest synchronization anchor. All 64-bit values are protected by timeMux
// because a 64-bit read/write need not be atomic on this processor.
volatile bool beaconValid = false;
volatile bool beaconPrintPending = false;
volatile uint32_t beaconSequence = 0;
volatile int64_t beaconMasterUs = 0;
volatile int64_t beaconLocalUs = 0;

// A button event includes a copy of the synchronization anchor that was valid
// at the instant of the press. A later beacon therefore cannot alter the event.
volatile bool pressLatched = false;
volatile bool pressPrintPending = false;
volatile uint32_t pressBeaconSequence = 0;
volatile int64_t pressLocalUs = 0;
volatile int64_t pressAnchorMasterUs = 0;
volatile int64_t pressAnchorLocalUs = 0;

void stopWithError(const char *message, esp_err_t error) {
  Serial.printf("%s: %s (%d)\n", message, esp_err_to_name(error), error);
  while (true) {
    delay(1000);
  }
}

// Arduino-ESP32 core 3.x receive callback. Record local reception time before
// validating or copying the packet so software work does not add to the anchor.
void onEspNowReceive(const esp_now_recv_info_t *info, const uint8_t *data,
                     int length) {
  const int64_t localReceiveUs = esp_timer_get_time();
  (void)info;

  if (length != static_cast<int>(sizeof(TimeBeacon))) {
    return;
  }

  TimeBeacon beacon;
  memcpy(&beacon, data, sizeof(beacon));

  if (beacon.magic != PACKET_MAGIC ||
      beacon.version != PROTOCOL_VERSION ||
      beacon.packetType != PACKET_TYPE_BEACON ||
      beacon.packetSize != sizeof(TimeBeacon)) {
    return;
  }

  portENTER_CRITICAL(&timeMux);
  beaconSequence = beacon.sequence;
  beaconMasterUs = beacon.masterTimeUs;
  beaconLocalUs = localReceiveUs;
  beaconValid = true;
  beaconPrintPending = true;
  portEXIT_CRITICAL(&timeMux);
}

void ARDUINO_ISR_ATTR onButtonFalling() {
  const int64_t localPressUs = esp_timer_get_time();

  portENTER_CRITICAL_ISR(&timeMux);
  if (beaconValid && !pressLatched) {
    pressLocalUs = localPressUs;
    pressBeaconSequence = beaconSequence;
    pressAnchorMasterUs = beaconMasterUs;
    pressAnchorLocalUs = beaconLocalUs;
    pressLatched = true;
    pressPrintPending = true;
  }
  portEXIT_CRITICAL_ISR(&timeMux);
}

void initializeEspNow() {
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);

  esp_err_t error =
      esp_wifi_set_channel(ESPNOW_CHANNEL, WIFI_SECOND_CHAN_NONE);
  if (error != ESP_OK) {
    stopWithError("Could not set the Wi-Fi channel", error);
  }

  error = esp_now_init();
  if (error != ESP_OK) {
    stopWithError("Could not initialize ESP-NOW", error);
  }

  error = esp_now_register_recv_cb(onEspNowReceive);
  if (error != ESP_OK) {
    stopWithError("Could not register the ESP-NOW receive callback", error);
  }
}

void printPendingBeacon() {
  bool shouldPrint = false;
  uint32_t sequence = 0;
  int64_t masterUs = 0;
  int64_t localUs = 0;

  portENTER_CRITICAL(&timeMux);
  if (beaconPrintPending) {
    shouldPrint = true;
    sequence = beaconSequence;
    masterUs = beaconMasterUs;
    localUs = beaconLocalUs;
    beaconPrintPending = false;
  }
  portEXIT_CRITICAL(&timeMux);

  if (shouldPrint) {
    Serial.printf("Beacon %" PRIu32 ": master=%" PRId64
                  " us, localRx=%" PRId64 ", offset=%" PRId64 " us\n",
                  sequence, masterUs, localUs, masterUs - localUs);
  }
}

void printPendingPress() {
  bool shouldPrint = false;
  uint32_t sequence = 0;
  int64_t localUs = 0;
  int64_t anchorMasterUs = 0;
  int64_t anchorLocalUs = 0;

  portENTER_CRITICAL(&timeMux);
  if (pressPrintPending) {
    shouldPrint = true;
    sequence = pressBeaconSequence;
    localUs = pressLocalUs;
    anchorMasterUs = pressAnchorMasterUs;
    anchorLocalUs = pressAnchorLocalUs;
    pressPrintPending = false;
  }
  portEXIT_CRITICAL(&timeMux);

  if (shouldPrint) {
    const int64_t elapsedSinceBeaconUs = localUs - anchorLocalUs;
    const int64_t networkButtonTimeUs =
        anchorMasterUs + elapsedSinceBeaconUs;

    Serial.println();
    Serial.println("BUTTON PRESSED");
    Serial.printf("  Beacon sequence: %" PRIu32 "\n", sequence);
    Serial.printf("  Elapsed since beacon: %" PRId64 " us\n",
                  elapsedSinceBeaconUs);
    Serial.printf("  Network button time: %" PRId64 " us\n",
                  networkButtonTimeUs);
  }
}

void rearmButtonAfterRelease() {
  static uint32_t releaseStartedMs = 0;

  bool isLatched;
  portENTER_CRITICAL(&timeMux);
  isLatched = pressLatched;
  portEXIT_CRITICAL(&timeMux);

  if (!isLatched) {
    releaseStartedMs = 0;
    return;
  }

  if (digitalRead(BUTTON_PIN) == LOW) {
    releaseStartedMs = 0;
    return;
  }

  if (releaseStartedMs == 0) {
    releaseStartedMs = millis();
    return;
  }

  if (millis() - releaseStartedMs >= RELEASE_DEBOUNCE_MS) {
    portENTER_CRITICAL(&timeMux);
    pressLatched = false;
    portEXIT_CRITICAL(&timeMux);

    releaseStartedMs = 0;
    Serial.println("Button released and rearmed.");
  }
}

}  // namespace

void setup() {
  Serial.begin(115200);
  const uint32_t serialWaitStarted = millis();
  while (!Serial && millis() - serialWaitStarted < 3000) {
    delay(10);
  }

  Serial.println();
  Serial.println("ESP-NOW time client");

  pinMode(BUTTON_PIN, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(BUTTON_PIN), onButtonFalling, FALLING);

  initializeEspNow();

  Serial.printf("Station MAC: %s\n", WiFi.macAddress().c_str());
  Serial.printf("ESP-NOW channel: %u\n", ESPNOW_CHANNEL);
  Serial.printf("Button: XIAO D1 / GPIO%u to GND\n", BUTTON_PIN);
  Serial.println("Waiting for time beacons...");
}

void loop() {
  printPendingBeacon();
  printPendingPress();
  rearmButtonAfterRelease();
  delay(1);
}

Emily ... I think this is sorta how this guy got his set up arranged ...reading through the documentation ...(more like a light skim actually) I noticed that he que'd the buzzers ... so if the first person failed to answer correctly ..by default , it will automatically illuminate the next fastest buzzer and they would have a chance to answer ..so on and so on ...don't know how I feel about that yet ...keep it or toss it to the wolves???? ...

just had a look ...