Introduction: Maze Game to Control With Smartphone

About: I like 100 yen shop. I like home improvement center. I like IKEA. I like motor sports.

Maze game to control with smart phone.

The maze moves according to the slope of the smartphone.

First of all, please see the video.

Motion image

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.
    https://www.thingiverse.com/thing:746116
  • 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

1. GPIO

Chattering is done with Rpi.GPIO installed in the standard.
Therefore, I will install pi-gpiod. This is because the PWM output is stable.

Installation method

sudo apt-get install pigpio python-pigpio python3-pigpio
http://abyz.me.uk/rpi/pigpio/index.html

Start the daemon.

sudo pigpiod

2. Node-RED

Install the library for pi-gpiod.
https://flows.nodered.org/node/node-red-node-pi-gpiod

Install the dashboard library for debugging.
https://flows.nodered.org/node/node-red-dashboard

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.

fig. http://192.169.1.000:1880/cam

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.

Happy instructables.

Epilog Challenge 9

Participated in the
Epilog Challenge 9

Raspberry Pi Contest 2017

Participated in the
Raspberry Pi Contest 2017

Remote Control Contest 2017

Participated in the
Remote Control Contest 2017