BeginnerGames
Pico Reaction-Time Game
A light turns on after a random pause; press a button quickly and see your reaction time in milliseconds.
Parts from the database
- Raspberry-Pi-Pico ร 1Microcontroller board
Other supplies
- Raspberry Pi Pico development boardCommon build supply
- LEDCommon build supply
- 330 ฮฉ resistorCommon build supply
- momentary pushbuttonCommon build supply
- breadboardCommon build supply
- USB data cableCommon build supply
- jumper wiresCommon build supply
Amazon links may be affiliate links. As an Amazon Associate, Electronics Hobby Hub earns from qualifying purchases.
Connections
- LED anode through 330 ฮฉ to GP15; LED cathode to GND.
- Pushbutton between GP14 and GND; the program enables the internal pull-up.
- Power the Pico by USB and use 3.3 V GPIO only.
Build steps
- Install the Raspberry Pi Pico Arduino board package and select the correct Pico/port.
- Wire LED and button as listed; check LED polarity.
- Upload the sketch. Wait for the LED to light, then press the button.
- Try five rounds and compare your best and average times; add a display later as an extension.
Software and firmware setup
const int led=15, buttonPin=14;
void setup(){ pinMode(led,OUTPUT); pinMode(buttonPin,INPUT_PULLUP); Serial.begin(115200); randomSeed(analogRead(A0)); }
void loop(){
digitalWrite(led,LOW); Serial.println("Wait..."); delay(random(1500,5000));
digitalWrite(led,HIGH); unsigned long start=micros();
while(digitalRead(buttonPin)==HIGH) { }
unsigned long elapsed=(micros()-start)/1000; digitalWrite(led,LOW);
Serial.printf("Reaction: %lu ms\n",elapsed);
delay(1200); while(digitalRead(buttonPin)==LOW) { }
}Test your build
The Serial Monitor should show the reaction time after each press. A false start currently ends the wait early; improving false-start detection is a good extension.
Troubleshooting
- If the LED stays off, reverse its leads or verify GP15.
- If the button seems always pressed, it may be wired to 3V3 instead of GND.
- If upload fails, hold BOOTSEL while reconnecting the Pico and select the new drive/port as instructed by the board package.
Safety and limitations
Use the Pico's USB supply; never connect an external 5 V signal to a Pico GPIO pin.
Manufacturer and platform documentation
Community Notes for This Project
These are unverified visitor contributions, separate from the build guide and manufacturer specifications. Verify technical advice against the linked datasheets before relying on it.
Set up the comments service to load community notes.