Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

ESP32C3 Supermini Based Interactive Reaction Game with RGB LED Effects and ESP-NOW Communication

View and Edit Project In Cirkit DesignerImage of ESP32C3 Supermini Based Interactive Reaction Game with RGB LED Effects and ESP-NOW Communication

Circuit Documentation

Summary

This circuit incorporates multiple components including two ESP32C3 Supermini microcontrollers, various resistors, pushbuttons, RGB LEDs, a Li-ion battery, a rocker switch, green and white LEDs, and a 5V Type C DC socket. The circuit is designed to facilitate a reaction time game, where players press a button in response to an LED signal. The ESP32C3 microcontrollers communicate with each other using ESP-NOW protocol to synchronize game states and determine the winner based on reaction times.

Component List

Microcontrollers

Resistors

Input Devices

Output Devices

Power Components

Actuators

Wiring Details

ESP32C3 Supermini

Resistors

Pushbutton

RGB LED (Wokwi compatible)

Li-ion battery 18650-2000mAh 3.7V 7.4WH

Rocker Switch

LED: Two Pin (green)

LED: Two Pin (white)

5V Type C DC Socket

Documented Code

ESP32C3 Supermini (Master)

#include <esp_now.h>
#include <WiFi.h>
#include <iostream>

// Define pin assignments
#define READY_LED_PIN 0
#define REACTION_LED_PIN 2
#define GREEN_LED_PIN 5
#define RED_LED_PIN 6
#define BLUE_LED_PIN 7
#define BUTTON_PIN 4

// Define timing constants
#define LONG_PRESS_DURATION 5000
#define SHORT_PRESS_DURATION 2000
#define MIN_DELAY 5000
#define MAX_DELAY 30000
#define NUMBER_MODES 5

// Define client address for ESP-NOW communication
uint8_t clientAddress[] = {0xD8, 0x3B, 0xDA, 0xE6, 0x91, 0x6C};

// Game state variables
bool masterReady = false;
bool clientReady = false;
bool gameActive = false;
bool gameStarted = false;
unsigned long buttonPressTime;
unsigned long reactionStartTime;
unsigned long masterReactionTime = 0;
unsigned long clientReactionTime = 0;

// LED flickering effect variables
unsigned long prevMillis = 0;
unsigned long flickerInterval = 100;

// Button state variables
bool buttonWasHeld = false;
int currentMode = 0;

// RGB LED color transition variables
const unsigned long interval = 50;
int redValue = 255;
int greenValue = 0;
int blueValue = 0;
int step = 5;

// Reaction LED state variables
bool reactionLedState = false;
bool buttonWasPressed = false;

// ESP-NOW message structure
typedef struct {
  char message[16];
  unsigned long reactionTime;
} esp_now_message;

// Function prototypes (to be implemented in the code)
void setup();
void loop();
void resetRGBLED();
void Fireworks();
void LGBTQ();
void controlFlameEffect(int pin_number);
void checkButton();
void startGame();
void playGame();
void onDataReceive(const esp_now_recv_info *info, const uint8_t *incomingData, int len);
void evaluateWinner();
void displayWinner();
void resetGame();
void sendMessage(const char *messageText);
void controlReactionLed();

// ... (rest of the code)

ESP32C3 Supermini (Client)

#include <esp_now.h>
#include <WiFi.h>

// Define pin assignments
#define LED_PIN 0
#define REACTION_LED_PIN 2
#define BUTTON_PIN 4

// Define timing constants
#define LONG_PRESS_DURATION 5000

// Define master address for ESP-NOW communication
uint8_t masterAddress[] = {0xD8, 0x3B, 0xDA, 0xE6, 0xB7, 0x50};

// Game state variables
bool clientReady = false;
bool gameActive = false;
bool gameStarted = false;
unsigned long buttonPressTime;
unsigned long reactionStartTime;
unsigned long clientReactionTime = 0;

// Reaction LED state variables
bool reactionLedState = false;
bool buttonWasPressed = false;

// ESP-NOW message structure
typedef struct {
  char message[16];
  unsigned long reactionTime;
} esp_now_message;

// Function prototypes (to be implemented in the code)
void setup();
void loop();
void checkButton();
void onDataReceive(const esp_now_recv_info *info, const uint8_t *incomingData, int len);
void playGame();
void displayWinner();
void resetGame();
void sendMessage(const char *messageText);
void sendReactionTime();
void controlReactionLed();

// ... (rest of the code)

This documentation provides an overview of the circuit, including a summary, detailed component list, wiring instructions, and documented code for the microcontrollers. The code snippets are partial and represent the structure and key elements of the embedded software.