Devices & Components
White LED 3mm
Buttons (generic)
1.2 K ohm resistor 10x
Active Buzzer 5V (HXD)
Wire, a bunch
Software & Tools
TINKERCAD
Project description
Code
code if using ardiuno
cpp
1// Define pins for buttons and buzzer 2const int buttonPins[9] = {2, 3, 4, 5, 6, 7, 8, 9, 10}; 3const int buzzerPin = 11; 4 5// Define pairs of buttons that complete the circuit 6const int circuitPairs[3][2] = { 7 {0, 1}, // Example pair, replace with your pairs 8 {2, 3}, 9 {4, 5} 10}; 11 12void setup() { 13 // Set button pins as inputs with internal pull-up resistors 14 for (int i = 0; i < 9; i++) { 15 pinMode(buttonPins[i], INPUT_PULLUP); 16 } 17 18 // Set buzzer pin as output 19 pinMode(buzzerPin, OUTPUT); 20} 21 22void loop() { 23 // Check for button presses 24 for (int i = 0; i < 3; i++) { 25 if (digitalRead(buttonPins[circuitPairs[i][0]]) == LOW && digitalRead(buttonPins[circuitPairs[i][1]]) == LOW) { 26 // Both buttons in a pair are pressed, complete the circuit 27 activateBuzzer(); 28 delay(1000); // Buzzer duration 29 deactivateBuzzer(); 30 delay(500); // Delay between attempts 31 } 32 } 33} 34 35// Function to activate the buzzer 36void activateBuzzer() { 37 digitalWrite(buzzerPin, HIGH); 38} 39 40// Function to deactivate the buzzer 41void deactivateBuzzer() { 42 digitalWrite(buzzerPin, LOW); 43}
Downloadable files
without ardiuno
puzzle game.png

curcuit diagram for ardiuno
puzzle game.txt
Comments
Only logged in users can leave comments