Schematic of this project:
Code: Reaction Game
#include <Arduino.h>#define A 2#define B 3#define C 4#define PWM_PIN 9#define INH 5#define BUTTON_PIN 6void setup() {pinMode(A, OUTPUT);pinMode(B, OUTPUT);pinMode(C, OUTPUT);pinMode(INH, OUTPUT);digitalWrite(INH, LOW); // Enable multiplexerpinMode(PWM_PIN, OUTPUT);pinMode(BUTTON_PIN, INPUT_PULLUP); // Button with pull-up resistorSerial.begin(9600);}void loop() {int randomLED = random(0, 8); // Pick a random LEDselectChannel(randomLED);analogWrite(PWM_PIN, 255); // Turn on LEDunsigned long startTime = millis();while (digitalRead(BUTTON_PIN) == HIGH); // Wait for button pressunsigned long reactionTime = millis() - startTime;Serial.print("Reaction Time: ");Serial.println(reactionTime);analogWrite(PWM_PIN, 0); // Turn off LEDdelay(1000); // Wait before next round}void selectChannel(int channel) {digitalWrite(A, channel & 0x01);digitalWrite(B, (channel >> 1) & 0x01);digitalWrite(C, (channel >> 2) & 0x01);}Find the full Project here:https://drive.google.com/file/d/1LNoW0uWOdzJTwrX-_cId1JDb2VolpdRl/view?usp=drive_link
Buy from your favorite bookstore:
https://books2read.com/u/bPjQNjBuy from your favorite bookstore:
https://books2read.com/u/bzwdezBuy from your favorite bookstore:
https://books2read.com/u/bxDQDJThis website is for electronics enthusiasts and beginners looking to dive into the world of Arduino and Raspberry Pi. It offers a wide range of hands-on tutorials, project guides, and code examples designed to help users build practical skills in embedded systems. Whether you're learning the basics of electronics or advancing your knowledge, this site provides step-by-step instructions, detailed schematics, and affiliate recommendations for quality hardware. Explore engaging projects, from simple LED controls to motion sensors, and start your journey into the exciting world of DIY electronics with easy-to-follow resources and expert advice.
0 Comments