Introduction: Maze Game to Control With Smartphone
Maze game to control with smart phone.
The maze moves according to the slope of the smartphone.
First of all, please see the video.
1. Raspberry Pi is a Websocket server.
2. The smartphone is a Websocket client.
3. The smartphone sends the tilt data to Raspberry Pi.
4. Raspberry Pi controls the servo according to the inclination data.
Step 1: Hardware Preparation
- Servo and servo folder
Servo uses Tower-pro SG90. Please refer to the URL for details. 3D data can also be downloaded.
- Maze game (light stuff, made with styrene board)
- Ball (Light stuff.)
- Raspberry Pi (using Raspberry Pi 3B)
- Smartphones (Prepare new browsers as much as possible.Safari Chrome Firefox)
Step 2: Connection
1. Connect the upper line to GPIO 12 (32 PIN).
2. Connect the lower line to GPIO 18 (12 PIN).
3. Align the direction of the servo.
Step 3: Setting Up Raspberry Pi
Chattering is done with Rpi.GPIO installed in the standard.
Therefore, I will install pi-gpiod. This is because the PWM output is stable.
sudo apt-get install pigpio python-pigpio python3-pigpio
Start the daemon.
Install the library for pi-gpiod.
Install the dashboard library for debugging.
3. Creating flow
Please import (Copy & Paste) the following files to Node-RED. Deploy when you can copy normally.
Step 4: Execution
1. Connect with a smartphone
Please connect your smartphone to WIFI on the same segment. Open the web browser and enter the IP address of Raspberry Pi.
2. Move the maze according to the slope of the smartphone. Let's keep slow motion.
Step 5: To the End
As it reacts sensitively to the movement of the smartphone, please correct the program and lower the sensitivity.
In that case please modify the function node of Node-RED.