An interactive kiosk-style slot machine that generates AI art using OpenAI's DALL-E 3. Users stop three spinning reels (Animal, Fruit, Object) and the system generates a unique "brainrot" themed image combining all three elements.
Designed for Raspberry Pi with physical GPIO buttons, but also works on desktop for development and testing.
- 3D Spinning Reels: Smooth CSS-based cylinder animations with realistic physics
- Physical GPIO Integration: Works with switches or push buttons on Raspberry Pi
- AI-Powered Generation: Uses GPT-4o-mini for creative prompts and DALL-E 3 for images
- Real-time WebSocket Communication: Instant feedback between hardware and UI
- Gallery System: View all generated images with metadata
- Kiosk Mode Ready: Fullscreen, cursor-hidden interface perfect for exhibitions
- Error Recovery: Automatic reset on API failures, robust handshake mechanism
- Custom typography using Adobe Typekit fonts (ironmonger-inlaid, freehouse)
- Golden yellow accent color (#ffcc33) with dark theme
- 3D CSS transforms for realistic reel effects
- Responsive animations optimized for Raspberry Pi performance
slotmachine/
├── backend/
│ └── main.py # FastAPI server with WebSocket & GPIO
├── frontend/
│ ├── index.html # Slot machine interface
│ ├── gallery.html # Image gallery viewer
│ ├── styles/
│ │ ├── common.css # Shared styles
│ │ ├── slot.css # Slot machine specific
│ │ └── gallery.css # Gallery specific
│ └── generated/ # Generated images & manifest
├── setup/ (Still needs to be tested)
│ ├── DEPLOYMENT.md # Complete Raspberry Pi guide
│ ├── setup_pi.sh # Auto-setup script
│ └── setup_kiosk.sh # Kiosk mode configuration
├── env/ # Python virtual environment
├── requirements.txt # Python dependencies
└── README.md
# Create virtual environment
python -m venv env
# Windows
env\Scripts\activate
# macOS/Linux
source env/bin/activate
# Install packages
pip install -r requirements.txtCreate a .env file:
OPENAI_API_KEY=sk-your-actual-key-hereuvicorn backend.main:app --reload --host 0.0.0.0 --port 8000The server starts on http://localhost:8000
- Slot Machine:
http://localhost:8000 - Gallery:
http://localhost:8000/static/gallery.html
Keyboard Controls (for testing without GPIO):
A,S,D- Stop reels A, B, CR- Reset
For complete Raspberry Pi setup with GPIO buttons and kiosk mode, see:
Quick setup:
# Transfer project to Pi
scp -r slotmachine/ pi@192.168.1.XXX:~/
# On the Pi
cd slotmachine
chmod +x setup/*.sh
bash setup/setup_pi.sh
# Edit .env with your OpenAI key
nano .env
# Optional: Enable kiosk mode
bash setup/setup_kiosk.sh- GPIO 23 → Reel A (Left - Animal)
- GPIO 27 → Reel B (Middle - Fruit)
- GPIO 22 → Reel C (Right - Object)
Works with both push buttons and toggle switches.
- Spin: Three reels start spinning automatically showing random items
- Stop: Press GPIO buttons (or A/S/D keys) to stop each reel
- Generate: After all reels stop, frontend sends handshake to backend
- Prompt: GPT-4o-mini creates a creative Italian name and DALL-E prompt
- Image: DALL-E 3 generates the image (1024x1024, vivid style)
- Display: Image appears fullscreen with metadata
- Gallery: All images saved with timestamps and accessible from gallery page
- Backend: FastAPI, WebSockets, gpiozero, pigpio
- Frontend: Vanilla HTML/CSS/JavaScript with 3D transforms
- AI: OpenAI GPT-4o-mini (prompts), DALL-E 3 (images)
- Hardware: Raspberry Pi with GPIO buttons/switches
- Deployment: systemd service, Chromium kiosk mode
# Check Python environment
which python
python --version
# Check dependencies
pip list | grep fastapi
# View errors
cd backend
python main.py# Check pigpiod service
sudo systemctl status pigpiod
# Test GPIO manually
python3 -c "from gpiozero import Button; Button(23).wait_for_press(); print('Works!')"- Verify OpenAI API key in
.env - Check network:
ping api.openai.com - View backend logs:
sudo journalctl -u brainrot-backend -f
- Uses handshake mechanism to prevent frontend/backend desync
- Supports both switch state changes and button presses
- Auto-reset on API errors with user-friendly messages
- Images saved to
frontend/generated/with JSONL manifest - CSS optimized for Raspberry Pi performance (no heavy animations)
- Keep
.envfile private (contains API key) - Change default Pi password
- Use static IP for stable kiosk deployment
- Consider firewall if exposing to network
MIT