Skip to content

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hardware-based reaction time check

After completing the following microcontroller course by Robocraze, I implemented my own game to test your reflexes using the same breadboard configuration they taught. Although it's somewhat elementary, I did learn a decent bit about ADC, PWM, GPIO, and interrupts by teaching myself to use my old Raspberry Pi I had lying around. Definitely helped my low-level programming skills by doing this entirely in C, without ever consulting AI, no less.

Prerequisite components

The full circuit looks pretty busy when it's all sitting on a breadboard, but I assure you that it's easier to comprehend than it looks. To assemble it the exact same way, you'll need:

  • A Raspberry Pi Pico W (to match the exact build, but any Raspberry Pi model post-2023 should work)
  • A regular-sized breadboard
  • Four double-pinned LED lightbulbs
  • Four buttons
  • An ungodly amount of jumper wires
  • A USB/USB-C cable to connect to your computer
IMG_1529

Double check your pin configuration so that the next few steps don't throw you for a loop.

All of the parts besides the Raspberry Pi came out of an ELEGOO starter kit I'd been neglecting as well. If anything was propelling me to finish this project besides my curiousity about hardware, it was definitely trying to get my money's worth out of all the gizmos I have at my disposal.

Program setup with Git

Make sure you have the necessary dependencies installed. Windows will have these set up by default, but for Linux and macOS systems, additional setup is required:

sudo pacman -S python git tar base-devel
sudo apt install python3 git tar build-essential
xcode-select --install

Once that's finished, clone the SDK and run the pico_setup.sh script. This may take some time.

sudo apt install wget
wget https://raw.githubusercontent.com/raspberrypi/pico-setup/master/pico_setup.sh

chmod +x pico_setup.sh
./pico_setup.sh
sudo reboot

If your machine is unable to run the Debian-based setup script (like mine), you can just pull the files directly from the repo:

git clone https://github.com/raspberrypi/pico-sdk.git
cd pico-sdk
git submodule update --init

You should be able to open the pico-sdk directory once that's completed. Inside, set a local path that build files will be able to recognize when compiling:

echo 'export PICO_SDK_PATH=~/path/to/pico-sdk/' >> ~/.zshrc
source ~/.zshrc

After all that's been completed, go back into the directory just outside of pico-sdk. This is where you can pull the repository for this project, which should be it for the setup!

Running the program on the Raspberry Pi

Pretty straightforward.

cd ../build
cmake ..
cd reaction_time_test
make -j$(nproc)

This will create a .uf2 file that can be booted onto the Raspberry Pi. To do this, hold down the BOOTSEL button on the device before plugging it into your computer. This should open a directory named RPI-RP2, that you can directly drag and drop reaction_time_test.uf2 into.

To see the output from the program, use minicom to view:

sudo minicom -b 115200 -o -D /dev/ttyACM0

About

Based on the circuit design demonstrated in the final lesson in Robocraze's "Raspberry Pi Pico using C/C++" video series. Lights LEDs at random time intervals and measures how quickly you can press their corresponding buttons. Takes the average of 10 button presses.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages