A simple 1d game for Raspberry Pi, using a DotStar LED strip as display. Guide a small worm to the other end of the LED strip by matching its color with the color of oncoming worms, going in the opposite direction.
Basic gameplay in place. Needs a lot of polishing and some good refactoring. :-)
- Raspberry Pi
- HC-SR04 ultrasonic sensor
- DotStar LED Strip
- Node.js v6 (see compatibility node below)
Developed on a Raspberry Pi 3, Model B
./install-Pi-specific-libs.sh && npm install && ./run.sh
npm test
Via a level-shifter, connect the DotStar DAT to Pi GPIO 10 and the DotStar CLK to Pi GPIO 11.
For details, see The Adafruit instruction.
Note, you need to hook up a quite beefy power brick to power the LED strip, at least 10A will be needed to handle the power draw of a lot of pixels firing at the same time. I ended up ordering a 5V, 15A brick. Should cover most scenarios.
In /boot/config.txt, uncommend the dtparam line to enable spi, like so:
# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
dtparam=spi=on
Hook up the senor ECHO pin to Pi GPIO17 and sensor TRIGGER pin to Pi GPIO04.
If those are not free, use other pins and set the corresponding pin numbers in ./config/GPIO-pins.js
.
The library used to interface with the ultrasonic sensor (HC-SR04) uses a depricated API and was not functioning properly with the latest Node.js for me.
- Write game engine, (DONE)
- Connect HC-SR04 ultrasonic sensor (PoC working outside this repo)
- Buy DotStar LED Strip (DONE Black friday hooray!)
- Connect DotStar LED Strip (DONE)
- Write display logic to render game to DotStar strip (DONE)
- Compose levels (DONE minimal)
- Clean code and build robust case
- Tweak difficulty
- Done!